Re: [R] Evaluating expresssions as parameter values

2009-10-01 Thread Erich Neuwirth
Let us walk through my problem step by step: 1. print(xyplot(yield ~ variety | site,groups=year,data=barley)) 2. print(xyplot(as.formula("yield ~ variety | site"),groups=year,data=barley)) The above two statements work, the next one does not work 3. print(xyplot(as.formula("yield ~ variety |

Re: [R] Evaluating expresssions as parameter values

2009-09-30 Thread Deepayan Sarkar
On Tue, Sep 22, 2009 at 12:03 PM, Erich Neuwirth wrote: > I need to play games with an expression similar to the following one: > > print(xyplot(DepVar ~ Group|Covar, groups=Othergroup, >        data=mydf, pch = 18 ,main="Testcase",auto.key = TRUE)) > > > The problem is that  the formula argument

Re: [R] Evaluating expresssions as parameter values

2009-09-23 Thread Peter Ehlers
Can't you just use get()? What am I missing? f <- function(fo, data, groups) { g <- xyplot(as.formula(fo), groups = get(groups), data) print(g) } f("yield ~ variety | site", data = barley, groups = "year") Peter Ehlers Erich Neuwirth wrote: Thanks, that completely solves the

Re: [R] Evaluating expresssions as parameter values

2009-09-22 Thread Erich Neuwirth
Thanks, that completely solves the problem. On Sep 22, 2009, at 10:27 PM, Gabor Grothendieck wrote: Try parse(text=...): f <- function(fo, data, groups) { g <- do.call("xyplot", list(as.formula(fo), groups = parse(text = groups), data)) print(g) } f("yield ~ va

Re: [R] Evaluating expresssions as parameter values

2009-09-22 Thread Gabor Grothendieck
Try parse(text=...): f <- function(fo, data, groups) { g <- do.call("xyplot", list(as.formula(fo), groups = parse(text = groups), data)) print(g) } f("yield ~ variety | site", data = barley, groups = "year") On Tue, Sep 22, 2009 at 4:20 PM, Erich Neuwirth wrote

Re: [R] Evaluating expresssions as parameter values

2009-09-22 Thread Erich Neuwirth
Thank you, this works for my example. On Sep 22, 2009, at 9:17 PM, Gabor Grothendieck wrote: > > f <- function(fo, data, groups) { > g <- do.call("xyplot", list(as.formula(fo), groups = as.name > (groups), data)) > print(g) > } But xyplot allows expressions for the groups parameter a

Re: [R] Evaluating expresssions as parameter values

2009-09-22 Thread Gabor Grothendieck
Try this: f <- function(fo, data, groups) { g <- do.call("xyplot", list(as.formula(fo), groups = as.name(groups), data)) print(g) } f("yield ~ variety | site", data = barley, groups = "year") On Tue, Sep 22, 2009 at 3:03 PM, Erich Neuwirth wrote: > I need to play games with a

[R] Evaluating expresssions as parameter values

2009-09-22 Thread Erich Neuwirth
I need to play games with an expression similar to the following one: print(xyplot(DepVar ~ Group|Covar, groups=Othergroup, data=mydf, pch = 18 ,main="Testcase",auto.key = TRUE)) The problem is that the formula argument (the first argument) an the groups argument are passed over from a