I'm trying to get code along the following lines to work:
temp.name <- paste(TimePt,'df',sep='.') # invent a relevant name/symbol as a
character string.
assign(temp.name,IGF.df[IGF.df$TPt==TimePt,]) # this works. The relevant
variable is now a data frame
lm(b ~ Strain+BWt+PWt+PanPix, data=temp.name)) # this gives an error, namely
Error in eval(predvars, data, env) : invalid 'envir' argument

I think it's obvious what I want to achieve, but how is it done? I tried
data=as.name(temp.name)
but that also didn't work. I can't find anything relevant in "Introduction
to R".

Here is a secondary question:
While trying to understand what assign() does, I looked up help(assign) and
found the example
a <- 1:4
assign("a[1]", 2)
a[1] == 2          #FALSE
get("a[1]") == 2   #TRUE
Could someone explain this puzzling example, or point me to an explanation
of environments and how to operate with them?

Thanks


-- 
View this message in context: 
http://r.789695.n4.nabble.com/puzzles-with-assign-tp2130691p2130691.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