[R] error reading data help please

Joshua Wiley jwiley.psych at gmail.com
Thu Apr 7 20:34:10 CEST 2011

Hi Oz,

On Thu, Apr 7, 2011 at 10:47 AM, Ouattara <B.Ouattara at swansea.ac.uk> wrote:
> Dear Readers,
> Sorry to bother you.
> Have been try to read my data into R (something I have done in the past) but
> having an error message with this one.
> Any possible help please?
> Thanks.
> Oz
> This is the error I am getting (please see bold):

This listserv only uses plain text emails (which is how the posting
guide respectfully requests you submit all queries).  HTML emails are
converted to plain text, so bold does not come through to us.

>> setwd("D:/Replication/")
>> dataFrame2=read.table("data.txt",header=T)
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
> :
>  line 1 did not have 58 elements

Assuming the data file is not malformed, try using a different
delimitter.  read.table() defaults to using space (sep = " ") I think,
but your data may be tab delimitted (sep = "\t"), or comma (sep =
","), or ...

If you are not certain, open your data in a regular text editor, and
see what sort of stuff is in between each cell (i.e., how can you tell
where one cell stops and another starts).  I think space, commas, and
tabs, are the most common, but there are many others.  More generally,
look through the documentation for ?read.table to get ideas for what
different arguments you might try to properly read in your data.

Hope this helps,


>        [[alternative HTML version deleted]]

^^ This is the part I mentioned where the list deletes HTML and only
sends us the plain text.

> ______________________________________________
> 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

^^ This is where you could have read that the list only sends plain text.

> and provide commented, minimal, self-contained, reproducible code.

Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles

More information about the R-help mailing list