[R] Odp: Creating Dummy Variables in R
Nordlund, Dan (DSHS/RDA)
NordlDJ at dshs.wa.gov
Wed Dec 16 23:44:40 CET 2009
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> Behalf Of whitaker m. (mw1006)
> Sent: Wednesday, December 16, 2009 2:14 PM
> To: Nikhil Kaza; Petr PIKAL
> Cc: r-help at r-project.org
> Subject: Re: [R] Odp: Creating Dummy Variables in R
>
> I have a much larger dataset than in my original email (attached - price dependent
> upon weight, Clarity (different levels IF-SI2), colour(levels D-L) and Cut (ideal-fair),
> and tried the regression command:
>
> >diamond.lm<-
> lm(price~weight+IF+VVS1+VVS2+VS1+VS2+SI1+SI2+I1+I2+D+E+F+G+H+I+J+K
> +L+ideal+excellent+very.good+good+fair, data="Diamonds2.txt")
>
> Error in eval(predvars, data, env) : invalid 'envir' argument
>
> Which lead to the error message below the command. I have tried searching for
> this, and assumed this was down to having categrocial variables within the data, is
> this a correct assumption or am i doing something else wrong? Apologies if this is a
> bit of a basic question!
>
> Thanks again,
> Matthew
You need to read your data from Diamonds2.txt into a dataframe first before running the lm() function. What does your file Diamonds2.txt look like?
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
More information about the R-help
mailing list