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

hkimscil hkimscil at scils.rutgers.edu
Sun May 5 22:21:11 CEST 2002


Hello all -
I must be wrong in using commands...  

The below is my data (test.data). Its size is 10 X 15.
1 1 1 1 1 1 0 1 1 1 1 1 0 1 0
1 1 1 0 0 1 0 0 0 1 0 0 1 1 1
1 1 1 0 0 1 0 1 0 0 0 1 1 1 1
0 0 0 0 1 1 0 0 0 1 1 0 0 1 1
1 1 1 1 0 1 0 1 0 1 0 0 0 1 1
0 1 0 0 0 1 0 0 0 1 1 0 1 0 0
1 1 0 1 0 1 1 1 0 0 1 0 1 0 0
1 1 0 1 0 1 1 1 0 1 0 1 1 0 0
0 1 1 1 1 1 1 0 1 1 0 1 1 0 0
1 1 0 0 0 1 0 0 1 0 1 1 1 0 0

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).

test1:
1 1 1 1 0 1 1 0 1 1 1 1 0 0 1
1 1 0 1 1 0 1 0 0 1 0 1 1 1 0
1 0 0 1 1 0 1 0 0 0 1 1 1 1 0
1 1 0 0 1 0 1 1 0 1 0 0 1 0 1
1 0 1 0 1 1 0 1 1 0 0 1 1 0 0
1 1 0 1 0 1 1 0 1 1 1 0 1 1 1
0 1 0 0 0 0 0 1 0 1 1 1 1 1 1
1 1 1 1 0 0 1 0 1 1 0 1 0 0 1
1 0 1 0 0 1 0 0 0 0 1 0 1 0 0
1 0 1 0 1 1 1 0 0 0 0 0 1 0 0

test2
1 1 1 1 1 1 0 1 1 1 1 1 0 1 0
1 1 1 0 0 1 0 0 0 1 0 0 1 1 1
1 1 1 0 0 1 0 1 0 0 0 1 1 1 1
0 0 0 0 1 1 0 0 0 1 1 0 0 1 1
1 1 1 1 0 1 0 1 0 1 0 0 0 1 1
0 1 0 0 0 1 0 0 0 1 1 0 1 0 0
1 1 0 1 0 1 1 1 0 0 1 0 1 0 0
1 1 0 1 0 1 1 1 0 1 0 1 1 0 0
0 1 1 1 1 1 1 0 1 1 0 1 1 0 0
1 1 0 0 0 1 0 0 1 0 1 1 1 0 0

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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