[R] import text file into R

Peter Ehlers ehlers at ucalgary.ca
Fri Jun 4 09:18:15 CEST 2010


On 2010-06-03 22:51, Dhanasekaran wrote:
> please look at the error..
>
>> LosA<-read.table("E:\\Temporary
> Tasks\\rub\\Los_R\\ca_los.txt",header=T,sep="\t")
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
> :
>    line 11022 did not have 87 elements

That error message seems pretty explicit to me: you have a problem with 
line 11022. Did you check it with a text editor?

It's always a good idea to run count.fields() on the file, as 
recommended on the help page for read.table.

If you're trying to import SAS data, you might want to check out the 
'foreign' package.

Note also that read.delim is convenient for tab-delimited files.

  -Peter Ehlers

>
> ca_los.txt is my tab delimited large text file which contains about 16lakhs
> observations.
>
> thank you
>
> On Fri, Jun 4, 2010 at 9:44 AM, Erik Iverson<eriki at ccbr.umn.edu>  wrote:
>
>> Dhanasekaran wrote:
>>
>>> Sorry guys....
>>>
>>> It is a tab delimited text file which I just exported from SAS. I want to
>>> import this in R. Pl let me know what is the delimiter I should use and R
>>> syntax.
>>>
>>> You still don't say the error you're getting when you try your read.table
>> command.
>>
>



More information about the R-help mailing list