[R] about lm

Berend Hasselman bhh at xs4all.nl
Fri Nov 16 20:53:09 CET 2012


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



More information about the R-help mailing list