[R] Importing Data.

Roger Peng rpeng at stat.ucla.edu
Thu Jul 18 00:50:30 CEST 2002


Try 

> m <- matrix(scan("filename", sep = ","), byrow = T, ncol = 2)

This will read the file and store in a m x 2 matrix.

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

On Wed, 17 Jul 2002, Jason C. Leach wrote:

> hi,
> 
> I'm a bit new to R and need a hand importing data.
> I have a text file of (x,y) pairs like:
> 
> x,y
> x,y
> x,y
> 
> I can read them in fine with read.table(), but I need to do some 
> cluster analysis on them, so I need it in a format cclust will
> understand, namely a Matrix.  Can anyone help with the code to
> to convert the data type?
> 
> 
> Thanks,
> j.
> 
> 
> 
> -- 
> ......................
> ..... Jason C. Leach
> .. 
> 
> Current PGP/GPG Key ID: 43AD2024 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

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