[R] Working around 256 byte variable names? + trouble opening large file
Steve Lianoglou
mailinglist.honeypot at gmail.com
Mon Sep 21 22:20:23 CEST 2009
Hi Aditi,
On Sep 21, 2009, at 4:04 PM, A Singh wrote:
> Dear R users,
>
> I am trying to read in a file with 105 columns, and when trying to
> attach it, get an error as follows:
>
>> vc1<-read.table("P:\\R\\Everything-I.txt", header=T, sep=" ",
>> dec=".",
> na.strings=NA, strip.white=T)
>> attach(vc1)
> Error in attach(vc1) : variable names are limited to 256 bytes
>
> Is there a way to get around this, and make R accept the given
> variable names? Or will I have to shorten them?
1. Don't use `attach`. Here's a good starting point to help you
develop your R coding style, I'm sending you straight to the section
about using "attach" :-)
http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html#attach
2. what do you get when you run "names(vc1)"?
> Also, when I try to read in a much larger file with 430 columns, I
> get the error:
>
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
> na.strings, :
> line 397 did not have 431 elements
>
> Is it that R isn't dealing too well with Excel-converted-to-text
> files? Is it a function of file size?
It's not a function of file size, but rather due to the fact that line
397 does not have as many data entries as the other lines .. maybe
this is a function of how excel is exporting the data?
> I have double-checked the 430 column file and all data seems to be
> in place.
How did you check the column to verify that? In Excel?
I'm not an excel guru, so I don't know how it handles data export when
certain cells are missing in a row -- each row should have as many
demarcated data points as any other. So if its a CSV, there should be
just as many ","'s in line 397 as there are in the preceding lines.
HTH,
-steve
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the R-help
mailing list