[R] NA - data.frame
R. Michael Weylandt
michael.weylandt at gmail.com
Thu Mar 15 01:31:04 CET 2012
Try this.
x <- matrix(1:3, nrow = 1)
y <- matrix(1:6, nrow = 1)
z <- matrix(1:10, nrow = 1)
library(plyr)
do.call("rbind.fill.matrix", list(x,y,z))
Note that x,y,z need to be made into matrices before this works.
Michael
On Wed, Mar 14, 2012 at 6:31 PM, Zenonn87 <zsolt.tarcai at hotmail.com> wrote:
> Hello!
>
> How can I top up with NA instead of repeat numbers when I am making
> data.frame?
> I have made vectors (6. peace) form a table with different length
> (5,10,15,20,25,30 data). I want put these vectors into a data.frame but in
> the smaller columns the numbers repeat continuously to fill up the empty one
> (because of the 30 element vector). How can I top up with NA instead of
> repeat numbers when I am making data.frame? I have a long solution (see
> below), but I guess there should be a simpler or shorter one. THX
>
> N30=c( prec[,1])
> N25=sample(N30,25)
> N20=sample(N25,20)
> N15=sample(N20,15)
> N10=sample(N15,10)
> N05=sample(N10,5)
> N05;N10;N15;N20;N25;N30
>
> N05=c(N05,rep(NA,25))
> N10=c(N10,rep(NA,20))
> N15=c(N15,rep(NA,15))
> N20=c(N20,rep(NA,10))
> N25=c(N25,rep(NA,05))
> (srb=as.data.frame(cbind(N05,N10,N15,N20,N25,N30)))
>
> --
> View this message in context: http://r.789695.n4.nabble.com/NA-data-frame-tp4473345p4473345.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list