[R] NA - data.frame

Zenonn87 zsolt.tarcai at hotmail.com
Wed Mar 14 23:31:05 CET 2012


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.



More information about the R-help mailing list