[R] Loading Dataset into R continual issue
Paul Hiemstra
paul.hiemstra at knmi.nl
Wed Mar 21 10:38:50 CET 2012
On 03/21/2012 06:35 AM, bobo wrote:
> Thank you. I was able to get it loaded however when I tried to run
>
> mod1<-lm(Pat2006~FHouse)
> I got
> Error in eval(expr, envir, enclos) : object 'Pat2006' not found
>
> What exactly is occurring here?
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Loading-Dataset-into-R-continual-issue-tp4486619p4491424.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
What is probably going wrong is that Pat2006 and FHouse are part of a
data.frame, as columns. If the columns are in the same data.frame, say
one called df:
mod1 <- lm(Path2006 ~ FHouse, data = df)
an alternative is to use assign to dump the columns as variables in your
workspace:
> speed
Error: object 'speed' not found
> attach(cars)
> speed
[1] 4 4 7 7 8 9 10 10 10 11 11 12 12 12 12 13 13 13 13 14 14 14
14 15 15
[26] 15 16 16 17 17 17 18 18 18 18 19 19 19 20 20 20 20 20 22 23 24 24
24 24 25
but I am very much in favor of the first solution using "data =". Using
attach fills up your workspace with a great deal of objects. Keeping the
columns in a data.frame is also better from a design point of view:
having them in one data.frame already groups together variables
(columns) that share a common background.
In addition:
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, *reproducible code*.
good luck,
Paul
--
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
More information about the R-help
mailing list