[R] Using read.table() with Excel data

Sean Davis sdavis2 at mail.nih.gov
Wed Mar 1 18:35:08 CET 2006




On 3/1/06 11:31 AM, "Nealy, David" <dnealy at rand.org> wrote:

> Help
> 
>  
> 
> I apologize if this message posts twice, but I do not think my last
> attempt went through.
> 
>  
> 
> I am trying to use the read.table() function to read in a massive
> alphanumeric data set.  I thought I might scan in each column
> individually and do a cbind() to reconstitute the array in R, so that
> maybe I could handle the numbers and the long lines of texts
> separately(some columns in the Excel dataset are wrapped lines of texts,
> some dates, some numbers).  However, I encountered a problem in that I
> cannot seem to even read the column of texts properly.  Each line of
> texts is fairly long and there are about 7000 lines.  When I try to read
> the entire 7000 lines, either R will say over 50 warnings() and then
> quite reading in the document or it will appear as though it
> successfully read the data, but then when I look at the dimension of the
> data, it is only 4000, and it will not print it to the screen.  When I
> take a small chunk of the text, say 40 lines, it prints to the screen,
> but much of the data is missing; usually only one true line of data
> shows up and the rest are NA's.  I was just wondering if I am going
> about reading this data set improperly?  Am I using the wrong function?
> Thanks a million your help is much appreciated.

Are you trying to read a .xls file, or is it tab-delimited text?

Assuming that it is text, make sure that there are no quote characters in
the file.  I sometimes find that setting quote="" in a call to read.table
does what I need.  Finally, I'm not sure how much difference reading each
column separately will make, so you might try reading as one call to
read.table to see if that works.

Sean




More information about the R-help mailing list