[Rd] Scan data from a .txt file

From: Vasundhara Akkineni <vasu.akkineni_at_gmail.com>
Date: Thu 17 Nov 2005 - 15:35:27 GMT


Hi all,
Am trying to read data from a .txt file in such a way that i can access the column names too. For example, the data in the table.txt file is as below:  Name Weight Height Gender
Anne 150 65 F
Rob 160 68 M
George 180 65 M
Greg 205 69 M
 i used the following commands:
 data<-scan("table.txt",list("",0,0,0),sep="")

a<-data[[1]]
b<-data[[2]]
c<-data[[3]]
d<-data[[4]]

 But this doesn't work because of type mismatch. I want to pull the col names also into the respective lists. For example i want 'b' to have (weight,150,160,180,205) so that i can access the col name and also the induvidual weights. I tried using the read.table method too, but couldn't get this working. Can someone suggest a way to do this. Thanks,
Vasu.

        [[alternative HTML version deleted]]



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Nov 18 02:38:42 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:33 GMT