[R] A very frustrating read.table error message

Jonathan Baron baron at psych.upenn.edu
Sun Jun 7 00:26:04 CEST 2009


On 06/06/09 15:02, Adam D. I. Kramer wrote:
> 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.  :)

count.fields()

More generally, you might be interested in our approach to integrating
data collection on the Web, using JavaScript, with R.  See

http://promberger.info/
(which says "private" but Google finds it pretty fast)
http://finzi.psych.upenn.edu/~baron/ex/template.htm
http://finzi.psych.upenn.edu/~baron/ex/template.html
http://finzi.psych.upenn.edu/~baron/R/template.R
http://finzi.psych.upenn.edu/~baron/R/TRIM.R

The last makes a nice data file out of the JavaScript output (which is
designed more to be readable at the moment than to be useful).  It
uses count.fields as a check.

None of this stuff is ready for prime time.  In my case, there is a
14-year history, with various baggage left over from earlier travels.

Jon
-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron




More information about the R-help mailing list