[R] eval parent.frame() twice

Rune Schjellerup Philosof rphilosof at health.sdu.dk
Fri Aug 7 12:19:23 CEST 2009


I want to use a function (update) that in its body uses
eval(call, parent.frame())

I would like to use this function in a function that does not contain
the variables referred to in 'call'. Those variables are instead in the
parent.frame() of my function (named 'second' below)

Like this:
a <- 2

evalu <- function(obj) {
 call <- obj$call
 eval(call, parent.frame())
first <- function() {
 a <- 3
 obj <- list(call=expression(a))
second <- function(obj) {
 eval(evalu(obj), parent.frame())

first() #returns 2, but I want 3.

How do I change 'second' such that the value of 'a' from 'first' is

Rune Schjellerup Philosof
Ph.d.-studerende, Statistik, IST, SDU

Telefon:  6550 3607
E-mail:   rphilosof at health.sdu.dk
Adresse:  J.B. Winsløwsvej 9, 5000 Odense C

More information about the R-help mailing list