[R] Odp: Creating Dummy Variables in R

whitaker m. (mw1006) mw1006 at soton.ac.uk
Wed Dec 16 23:14:09 CET 2009


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
________________________________________
From: Nikhil Kaza [nikhil.list at gmail.com]
Sent: Wednesday, December 16, 2009 4:14 PM
To: Petr PIKAL
Cc: whitaker m. (mw1006); r-help at r-project.org
Subject: Re: [R] Odp:  Creating Dummy Variables in R

I don't think R will complain, if you use the approach below. However,
IF, VVS1 and VVS2 are linearly dependent.
Better use the factor approach and define which factor should be the
contrast

Nikhil

On 16 Dec 2009, at 10:12AM, Petr PIKAL wrote:

> what commands did you use for regression
>
> I suppose
>
> lm(Price~Weight+IF+VVS1+VVS2, data=your.data)
>
> shall not complain if your.data is a data frame.
>
> Regards
> Petr

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Diamonds2.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091216/1f083a79/attachment-0002.txt>


More information about the R-help mailing list