Displaying 1 result from an estimated 1 matches for "the_txt".
2011 Jan 29
1
environment question: changing variables from a formula through model.frame?
...at will take a formula of y~x and will (try and
*fail* to) change "y" (only) inside the environment of this function:
foo1 <- function(formu)
{
print("Before changing the 'y' variable in the formula")
print(model.frame(formu))
temp_y <- model.frame(formu)[,1] +10
the_txt <- paste(names(model.frame(formu))[1], "temp_y", sep = "<-")
eval(parse(text = the_txt)) # jutter out y var so to be able to handle
identical values.
print("After changing the 'y' variable in the formula")
print(model.frame(formu))
# why isn't it p...