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

Dimitri Liakhovitski dimitri.liakhovitski at gmail.com
Fri Oct 22 15:15:06 CEST 2010


I have run into this problem and think, most likely it is what Ivan
said above. It's happening because you (or someone before you) has
done something in those empty cells - formatted them, unformatted
them, etc.
Just highlight the area in Excel you want to read in (excluding all
those rows/columns you don't want), paste them into a new Excel file,
save as .csv - and then it should work.
Dimitri


On Fri, Oct 22, 2010 at 7:11 AM,  <J.delasHeras at ed.ac.uk> wrote:
> Quoting Petr PIKAL <petr.pikal at precheza.cz>:
>
>
>> 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
>
> When a file doesn't seem to read well, I just read it line by line using
> 'readLines', as Petr suggests.
> That reads the whole file (or part of it if you choose that) on a per-line
> basis. Then you can explore these lines and see the structure... whether
> there are extra comment lines you didn't count on, or strange formatting...
> sometimes quotation marks can be problematic... or an apostrophe within a
> text cell... or tehre are characters present in teh middle of teh data that
> read* took as a comment mark...
> doing readLines, then you can split each line as required (use 'strsplit')
> It seems complicated, but when you're not exactly sure of the format of a
> file you've been given, or you get unexpected results, readLines is very
> useful and an extra 3-4 lines of code will sort the data after you have a
> look inside.
>
> Jose
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
> ______________________________________________
> 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.
>



-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com



More information about the R-help mailing list