简体   繁体   中英

Error in eval(predvars, data, env): object 'V1' not found

I'm trying to use the linear regression's tools:

data=read.table("http://users.stat.ufl.edu/~winner/data/pgalpga2008.dat",  check.names=FALSE)

Then I have to select only female golfers so I did:

datF <- subset(data, V3==1, select=1:2)

Where V3 is the label of the third column. Now I should apply the linear regression method so I did:

datF.lm=lm(V1~V2)

Where V1 and V2 are the label of the other two column but I came through this error and I can't understand why.

Yes, as slava-kohut states, the lm() function requires a reference to the dataframe as one of its arguments. If you don't specify data = datF , lm() doesn't know where to look for the variables V1 and V2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM