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



--
View this message in context: 
http://r.789695.n4.nabble.com/Unable-to-reference-variable-created-in-dataframe-tp4640822.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to