[R] trouble in (scan -- read.table)

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Sun May 5 22:06:58 CEST 2002


"hkimscil" <hkimscil at scils.rutgers.edu> writes:

> I am importing the data into a matrix test1, using scan.
> > test1<-matrix(scan("test.data"),nrow=10,ncol=15)
> 
> Then, I do the same thing with read.table
> > test2<-as.matrix(read.table("test.data"))
> 
> Now, test1 and test2 are different (test2 is the correct one).

You need byrow=TRUE in matrix()

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list