about lm

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

about lm

Sonia Amin
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: about lm

Rui Barradas
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]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: about lm

Bert Gunter
In reply to this post by Sonia Amin
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 <[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: about lm

Berend Hasselman
In reply to this post by Sonia Amin

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
______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: about lm

FJ M
In reply to this post by Sonia Amin

dat=read.csv("c:\\ven.csv",header=TRUE,sep=";");
attach(attach(dat))
dat  
lm.1<-lm(ve~ su)
summary(lm.1)
 
GL Frank

> Date: Fri, 16 Nov 2012 20:42:39 +0100
> From: [hidden email]
> To: [hidden email]
> 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]]
>
> ______________________________________________
> [hidden email] 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.
     
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: about lm

Michael Weylandt
On Sat, Nov 17, 2012 at 12:29 PM, FJ M <[hidden email]> 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: about lm

David Winsemius
In reply to this post by FJ 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: [hidden email]
>> To: [hidden email]
>> 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: about lm

FJ M

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.
 
Thanks,
 
Frank
 
 

> CC: [hidden email]; [hidden email]
> From: [hidden email]
> To: [hidden email]
> 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: [hidden email]
> >> To: [hidden email]
> >> 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
>
     
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: about lm

Michael Weylandt
On Sat, Nov 17, 2012 at 4:56 PM, FJ M <[hidden email]> 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: about lm

David Winsemius
In reply to this post by FJ M

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: [hidden email]; [hidden email]
> > From: [hidden email]
> > To: [hidden email]
> > 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: [hidden email]
> > >> To: [hidden email]
> > >> 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

______________________________________________
[hidden email] 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.