Skip to content
Prev 8054 / 398506 Next

R help for a newby

tmed <tmed at pacbell.net> writes:
matrix(scan("mydata-file"), ncol=5, byrow=TRUE)

or

do.call("cbind", scan("mydata-file", what=rep(0,5)))

or

as.matrix(read.table("mydata-file"))
 
should all work ("should" being code for "I didn't actually try"). I'd
expect the middle one to be the most efficient, but who knows.

BTW: Accessing an element of a matrix is dat[1,1] in R, not dat[1][1]
as in C.
Um, please try to avoid that stuff. It looks bad in some peoples
mailers, and I think it also messes with the list digests.