Steve, I tried to replicate your error, but couldn't do it. The code below works just fine for me. Does it for you?
# create an example data frame Bridges <- data.frame(CONDITION=1:5, TRAFFIC=rnorm(5), WEATHER=rnorm(5)) # create new variable "LOG_COND" Bridges$LOG_COND = log(Bridges$CONDITION, base = exp(1)) # fit linear model lm.bridges = lm(LOG_COND ~ TRAFFIC + WEATHER, data = Bridges) Jean slavrenz <slavr...@purdue.edu> wrote on 08/20/2012 02:30:31 PM: > > Hello, I have question about referencing a variable that I created in a > dataframe, and I am hoping the experts on here can be of assistance. I have > a dataset of highway bridges with approximately 10,000 observations. I > imported these into R in the form of a dataframe called "Bridges". > > I am interested in running some basic linear models on a few key variables > with the data. Say "CONDITION" is my dependent variable, and "TRAFFIC" and > "WEATHER" are the independent variables I am considering. In order to > capture a possible exponential relationship between "CONDITION", "TRAFFIC", > and "WEATHER", I created the variable "LOG_COND": > > Bridges$LOG_COND = log(Bridges$CONDITION, base = exp(1)) > > I then used the "str" command to verify that the variable shows up > correctly, and is of the correct form (numeric) in the dataframe. > > However, when I then attempt to use my new variable, say, for example: > > lm.bridges = lm(LOG_COND ~ TRAFFIC + WEATHER, data = Bridges), (not > sure why the tilde symbol shows up as a minus sign here) > > I get "Error in eval(expr, envir, enclos) : object 'LOG_COND' not found" > > Can anyone enlighten me as to what I am doing wrong, and if possible, some > basic code that I can use to rectify the situation? I am a pretty basic R > user right now, so I'm definitely looking for something that is more > functional than elegant. > > Thanks, > > -Steve [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.