Re: [R] how to important a date file into R

From: Carl Witthoft <carl_at_witthoft.com>
Date: Sun, 08 Jun 2008 15:20:46 -0400


> 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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 08 Jun 2008 - 19:31:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 08 Jun 2008 - 20:32:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive