[R] how to important a date file into R

Carl Witthoft carl at witthoft.com
Sun Jun 8 21:20:46 CEST 2008


 > Hi:
 > I have a data file in the following format. The first three digits 
stand for the ID of a respondent such as 402, 403. Different respondents 
may have the same ID. Followed the ID are 298 single digit number 
ranging from 1 to 5. My question is how to read this data file into R. I 
tried "scan" and "read" but they do not work because the numbers in the 
file are not separated. Any suggestions?
 > Thank you!
 >

The answers provided to date (read.fwf()) look just fine.   I thought 
I'd mention that you could always pre-process the data file in any text 
editor to insert commmas or tabs between every number (other than that 
leading 3-digit number) and then use scan() or read.csv()

Carl



More information about the R-help mailing list