[R] reading in vectors from text files

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon Mar 21 08:29:33 CET 2005


Rashmi Mathur wrote:

> Hello,
> 
> I am trying to read in a file of data using read.table(), in which the
> data in one column is vectors.
> 
> The format of the file is as follows -
> 
> 
> FirstName	LastName	no.Children		children.ages
> Sally		James		3			c(3,5,7)
> John		Smith		2			c(13,16)
> Betsy		Harold	6			c(2,5,8,12,15,17)
> 
> 
> How do I specify that the children.ages column contains vector data, and
> that each vector is of a different length when reading in this text
> file?

You might want to read the column as character, parse it afterwards, and 
convert your data structure into a list which seems more appropriate to 
represent the data.

Uwe Ligges


> Thanks in advance,
> Rashmi
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list