[R] error reading data help please
Ouattara
B.Ouattara at swansea.ac.uk
Thu Apr 7 23:30:01 CEST 2011
Thanks Josh for your help. The tab delimited option worked.
Best wishes,
Oz
-----Original Message-----
From: Joshua Wiley [mailto:jwiley.psych at gmail.com]
Sent: 07 April 2011 19:34
To: Ouattara
Cc: r-help at r-project.org
Subject: Re: [R] error reading data help please
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/")
>
>>library(gmp)
>
>> 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,
Josh
>
>
> [[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
http://www.joshuawiley.com/
More information about the R-help
mailing list