An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121116/2c2b0454/attachment.pl>
about lm
10 messages · Sonia Amin, Rui Barradas, Bert Gunter +4 more
Hello, 1. Don't call your dataset 'data', it's the name of an R function. 2. Imagine it's called 'dat'. Then you must use the lm() argument data = dat. Like this: lm(ve~ su, data = dat) Hope this helps, Rui Barradas Em 16-11-2012 19:42, Sonia Amin escreveu:
Dear friends,
I have a csv file entitled ven.csv located in C:\\, this file contains only
two columns:"ve" and "su" I have written the following lines:
data=read.csv("c:\\ven.csv",header=TRUE,sep=";");
lm(ve~ su)
I have obtained the following message:
Error in eval(expr, envir, enclos) : object 've' does not exist. What's the
problem? thank you for your help in advance
[[alternative HTML version deleted]]
______________________________________________ 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.
I quote Rolf Turner: "Learn something about R; don't just hammer and hope. Read the introductory manuals and scan the FAQ." The answer is that your data are in "data," but until you make a greater effort to learn R, I'm not sure this will be helpful to you. Cheers, Bert
On Fri, Nov 16, 2012 at 11:42 AM, Sonia Amin <soniaamin5 at gmail.com> wrote:
Dear friends,
I have a csv file entitled ven.csv located in C:\\, this file contains only
two columns:"ve" and "su" I have written the following lines:
data=read.csv("c:\\ven.csv",header=TRUE,sep=";");
lm(ve~ su)
I have obtained the following message:
Error in eval(expr, envir, enclos) : object 've' does not exist. What's the
problem? thank you for your help in advance
[[alternative HTML version deleted]]
______________________________________________ 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.
Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
On 16-11-2012, at 20:42, Sonia Amin wrote:
Dear friends,
I have a csv file entitled ven.csv located in C:\\, this file contains only
two columns:"ve" and "su" I have written the following lines:
data=read.csv("c:\\ven.csv",header=TRUE,sep=";");
lm(ve~ su)
I have obtained the following message:
Error in eval(expr, envir, enclos) : object 've' does not exist. What's the
problem? thank you for your help in advance
Your ve and su are in the dataframe "data". (Don't use data as name for R objects; it is a builtin function). They are not in the environment from which lm is called (in this case probably the global environment). You haven't specified that ve and su are in dataframe "data". So ?lm and look at the description of the "data" argument in the section "Arguments". lm(ve~su, data=data) should work. Berend
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121117/fce9cebb/attachment.pl>
On Sat, Nov 17, 2012 at 12:29 PM, FJ M <chicagobrownblue at hotmail.com> wrote:
dat=read.csv("c:\\ven.csv",header=TRUE,sep=";");
attach(attach(dat))
Ahh! Two at once! Why -- for the love of god, why! :-P M
On Nov 17, 2012, at 4:29 AM, FJ M wrote:
dat=read.csv("c:\\ven.csv",header=TRUE,sep=";");
attach(attach(dat))
It is generally less error prone to avoid attach (even once).
dat lm.1<-lm(ve~ su)
And instead use: lm.1<-lm(ve~ su, data=dat)
summary(lm.1) GL Frank
Date: Fri, 16 Nov 2012 20:42:39 +0100
From: soniaamin5 at gmail.com
To: r-help at r-project.org
Subject: [R] about lm
Dear friends,
I have a csv file entitled ven.csv located in C:\\, this file
contains only
two columns:"ve" and "su" I have written the following lines:
data=read.csv("c:\\ven.csv",header=TRUE,sep=";");
lm(ve~ su)
I have obtained the following message:
Error in eval(expr, envir, enclos) : object 've' does not exist.
What's the
problem? thank you for your help in advance
[[alternative HTML version deleted]]
When you do get around to reading the Posting Guide, please note the section where the request to NOT post in HTML is made.
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD Alameda, CA, USA
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121117/96b82a9b/attachment.pl>
On Sat, Nov 17, 2012 at 4:56 PM, FJ M <chicagobrownblue at hotmail.com> wrote:
attach(attach(dat)) should be attach(dat) Is attach() broken? I've been using attach() successfully for months. I was surprised that header=TRUE did not map the headers to the data. But since attach() worked, I've never asked for an enhancement to the various read functions.
No -- it's not broken, but it is dangerous (or more properly, confusing). It has non-local effects by creating a whole bunch of variables in the search path all at once. Combine that with the fact that those new variables can't be written to and an apparent sub/re-assignment really only creates global-environment copies (also somewhat magically) and you have a recipe for confusion. It's of course actually very important to the workings of R -- it's key to package loading, inter alia -- but in my alternate universe, it'd be hidden away, or at least start with a dot so it looks scarier. Michael
On Nov 17, 2012, at 8:56 AM, FJ M wrote:
attach(attach(dat)) should be attach(dat) Is attach() broken? I've been using attach() successfully for months. I was surprised that header=TRUE did not map the headers to the data.
???. 'header=TRUE' changes how read.table() and derivatives handle the first line of a input file. You may be expressing surprise that the the names of list elements are not in the search path. (Dataframes are lists.)
But since attach() worked, I've never asked for an enhancement to the various read functions. Thanks, Frank
CC: soniaamin5 at gmail.com; r-help at r-project.org From: dwinsemius at comcast.net To: chicagobrownblue at hotmail.com Subject: Re: [R] about lm Date: Sat, 17 Nov 2012 08:31:01 -0800 On Nov 17, 2012, at 4:29 AM, FJ M wrote:
dat=read.csv("c:\\ven.csv",header=TRUE,sep=";");
attach(attach(dat))
It is generally less error prone to avoid attach (even once).
dat lm.1<-lm(ve~ su)
And instead use: lm.1<-lm(ve~ su, data=dat)
summary(lm.1) GL Frank
Date: Fri, 16 Nov 2012 20:42:39 +0100
From: soniaamin5 at gmail.com
To: r-help at r-project.org
Subject: [R] about lm
Dear friends,
I have a csv file entitled ven.csv located in C:\\, this file
contains only
two columns:"ve" and "su" I have written the following lines:
data=read.csv("c:\\ven.csv",header=TRUE,sep=";");
lm(ve~ su)
I have obtained the following message:
Error in eval(expr, envir, enclos) : object 've' does not exist.
What's the
problem? thank you for your help in advance
[[alternative HTML version deleted]]
When you do get around to reading the Posting Guide, please note the section where the request to NOT post in HTML is made.
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
-- David Winsemius, MD Alameda, CA, USA
David Winsemius, MD Alameda, CA, USA