Dear Colleagues,

        Occasionally I deal with computer-generated (i.e., websurvey) data
files that haven't quite worked correctly. When I try to read the data into
R, I get something like this:

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
:
  line 26 did not have 648 elements

...is there any way to get R to tell me how many elements line 26 *did*
have? That information would take this error message from frustrating to
useful.  :)

In the specific case today, it DID have 648 elements (produced using perl
splitting on the sep="\t" I had passed to read.table), but R was thrown off
by the fact that line 26 contained \xD characters when the newline for the
file was supposed to be just \n...because there was a text input field into
which respondants had put carriage returns. The web survey software was
smart enough to encode these differently than it encoded newlines, but this
threw R off somehow.

Also, there doesn't appear to be a way to specify what a newline should look
like in ?read.table, so I just manually went through the data file and
replaced \xD with ' '...perhaps read.table should allow for newline
specification?

--
Adam D. I. Kramer
Ph.D. Candidate, Social and Personality Psychology
a...@uoregon.edu

______________________________________________
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