Trying to understand environments is not for the faint of heart. If
lists do what you want then I would stick with a list and not worry
about the environments. Most of the time that you deal with
environments everything happens automatically behind the scenes and
you don't need to worry about
Greg Snow 538280 at gmail.com writes:
The take home message that you should be learning from your struggles
is to Not Use The 'assign' Function! and Do Not Use Global
Variables Like This.
R has lists (and environments) that make working with objects that are
associated with each other
The take home message that you should be learning from your struggles
is to Not Use The 'assign' Function! and Do Not Use Global
Variables Like This.
R has lists (and environments) that make working with objects that are
associated with each other much simpler and fits better with the
functional
Julio Sergio Santana juliosergio at gmail.com writes:
I have a data frame whose first colum contains the names of the variables
and whose second colum contains the values to assign to them:
: kkk - data.frame(vars=c(var1, var2, var3),
vals=c(10, 20, 30),
David Winsemius dwinsemius at comcast.net writes:
So what happens if you try this:
mapply(assign, kkk$vars, kkk$vals, MoreArgs = list(envir = .GlobalEnv)
Yes, it works in certain situations, as well as the equivalent code:
kkk - data.frame(vars=c(var1, var2, var3),
I have a data frame whose first colum contains the names of the variables
and whose second colum contains the values to assign to them:
: kkk - data.frame(vars=c(var1, var2, var3),
vals=c(10, 20, 30), stringsAsFactors=F)
If I do
: assign(kkk$vars[1], kkk$vals[1])
On Dec 6, 2013, at 11:27 AM, Julio Sergio Santana wrote:
I have a data frame whose first colum contains the names of the variables
and whose second colum contains the values to assign to them:
: kkk - data.frame(vars=c(var1, var2, var3),
vals=c(10, 20, 30),
7 matches
Mail list logo