[R] Problem importing .txt file
Sarah Goslee
sarah.goslee at gmail.com
Wed Jan 18 23:06:14 CET 2012
It's hard to diagnose the problem with importing the file without
the file itself, but you can easily change the column names:
colnames(Lambs) <- c("Kind", "Fatness", "Wt")
You should also open the text file itself and check that everything
looks okay with the first few rows.
Sarah
On Wed, Jan 18, 2012 at 4:39 PM, Berneet Kaur
<berneet.kaur at ucdmc.ucdavis.edu> wrote:
>
>
> Hello, I hope I am doing this correctly, though I am not sure if a response
> will be posted somewhere or if I will get a direct response. I am trying to
> import a .txt table in my class on R and for some reason, the header gets
> altered and I can no longer read the data. No one in my class had this
> problem and the instructors were not sure how to fix it.
> Here is the text table:
> Kind Fatness Wt
> Ewe 4 10.3
> Ewe 8 11.9
> Ewe 11 15
> Ewe 15 17.1
> Ewe 15 18.7
> Ram 5 12.4
> Ram 4 14.3
> Ram 10 16.6
> Ram 8 18.8
> Ram 14 21.9
> Here is the code that I copied from the instructors handout (simple cut and
> paste, no alterations):
> Lambs = read.table("Lambs.txt", header = TRUE)
> > Lambs
> ï..Kind Fatness Wt
> 1 Ewe 4 10.3
> 2 Ewe 8 11.9
> 3 Ewe 11 15.0
> 4 Ewe 15 17.1
> 5 Ewe 15 18.7
> 6 Ram 5 12.4
> 7 Ram 4 14.3
> 8 Ram 10 16.6
> 9 Ram 8 18.8
> 10 Ram 14 21.9
> > par(mfrow = c(1, 2))
> > plot(Fatness ~ Kind, data = Lambs)
> Error in eval(expr, envir, enclos) : object 'Kind' not found
>
>
> I think it is because the "Kind" header got altered into " ï..Kind" and it
> can no longer identify the object.
> Can anyone help?
> Thanks
--
http://www.functionaldiversity.org
More information about the R-help
mailing list