[R] matrix problem

Wu Gong wg2f at mtmail.mtsu.edu
Tue Aug 10 21:05:30 CEST 2010


Hi,

I guess you just want to reshape your data to wide format.

strs <- "Index Time Value
1 2 0.1
2 3 0.2
3 1 0.3"
DF <- read.table(textConnection(strs),header=T)
rDF <- reshape(DF, idvar="Index", timevar="Time", direction="wide") 
rDF[is.na(rDF)] <- 0

-----
A R learner.
-- 
View this message in context: http://r.789695.n4.nabble.com/matrix-problem-tp2320193p2320287.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list