[R] Odp: importing csv gets me all 16,000 columns with "NA"

Ivan Calandra ivan.calandra at uni-hamburg.de
Fri Oct 22 09:48:29 CEST 2010


  Hi,

I'm not sure I completely understand your problem (since you didn't 
provide much info), but I had a similar problem.
It happened to me that R read several columns that are supposed to be 
empty, and therefore fills them with NA. I've noticed that it is so 
because these extra columns were formatted in Excel (e.g. you selected a 
complete line and changed the font; all the cells on that line are 
therefore "present").
To get around, I just copy only the filled cells into a new spreadsheet 
and save it again. The importation in R then works fine.

As I said, not sure it is your problem.

HTH,
Ivan

Le 10/22/2010 09:25, Petr PIKAL a écrit :
> Hi
>
> You did not provide much info for help. What is size of imported file
> (columnsxrows)?
>
> r-help-bounces at r-project.org napsal dne 22.10.2010 01:23:03:
>
>> I'm new to R. I have a mac (OS10.6). I have converted an Excel file to a
> csv
>> to import into R. I have used many methods to import the file, most do
> not
>> work, the best so far is:
>>
>> filename<- read.csv(/Users/Desktop/csvfile.csv", header=T, sep=","). I
> have
>> also tried taking out the header and sep lines and it still imports
> fine.
>
> Imports fine or not?
>
>> Regardless of what I do, it always brings in the data but also includes
> all
>> 16,000+ columns from Excel with X.1 as the first column up to X.16345
> (for
>> instance). Of course the files are filled with "NA" since no data is
>> present.
> It seems that this file have no header or the header are numbers from 1 to
> 16345
>
>> How do I get around this?
>>
>> So far I have included strip.white=T and fill=T, something I've seen in
>> other csv import posts but this does not work.
> There are many ways how to import whole file by read.* commands but you
> could also check scan or readLines functions. The result always depends on
> looklike of your input file (separators, decimals, missing values etc.)
>
> Regards
> Petr
>
>> Thanks!
>> -- 
>> View this message in context:
> http://r.789695.n4.nabble.com/importing-csv-
>> gets-me-all-16-000-columns-with-NA-tp3006480p3006480.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> 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.
> ______________________________________________
> 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.
>

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php



More information about the R-help mailing list