[R] read.table with many blanks (reposting)

David Winsemius dwinsemius at comcast.net
Wed Nov 12 08:30:16 CET 2008


If you do not have any separators in the original file, than you need  
to read it as a fixed width format for which you need read.fwf.  Since  
there are no commas in your file you certainly would not want to use  
read.csv

You are still sending html-formatted mail, so its possible that you  
have tabs that we can't see. Tabs would be interpreted properly as  
separators by read.table.  Please set up your mail client to send  
plain text.

Have you read the R Data Import/Export manual yet?

-- 
David Winsemius
Heritage Labs


On Nov 12, 2008, at 12:23 AM, keunhchoi at gmail.com wrote:

> Thanks Jim for pointing out how to properly ask.
> Here is is my question and a small subset of the data and output.
>
> I have a data set with many blanks. The blanks should be replaced  
> with zero
> once imported.
> I tried read.table, read.csv (R 2.8 version),or scan, but none was
> successful.
> Any suggestion, please..
>
> thanks.
> Keun-Hyung
>
>> garoben=read.table("c:\\Rdata\\garoben.txt",header=T, fill=0,  
>> as.is=TRUE)
>
>> error:
> scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
> 11 missing components
>
> ## the data look like this
>
>       Am.auricula    Am.arctica    Am.gunneri    An.koreana
> Ar.iricolor    Ar.lanceolata
> 4
> 5        19.2             19.2
> 6                                                 57.7
> 7        19.2
> 8        19.2              19.2
> 9        19.2
> 10       19.2            19.2                19.2
> 11
> 12
> 13
> 14        153.8         19.2               19.2                19.2
>    19.2            19.2
> 15        1423.1
> 16
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list