Quoting Petr PIKAL <petr.pi...@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@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.

Reply via email to