Skip to content
Prev 101933 / 398500 Next

Fill a matrix with vectors of different lengths

you can try something like the following:

out <- lapply(1:length(v), function(i) binc(v[1:i]))
nout <- max(sapply(out, length))
sapply(out, function(x) c(x, rep(0, nout - length(x))))


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Serguei Kaniovski" <kaniovsk at wifo.ac.at>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, October 16, 2006 10:27 AM
Subject: [R] Fill a matrix with vectors of different lengths
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm