Re: [R] ggplot2 used in a function - variable scope/environment

2008-02-16 Thread Martin Rittner
Hi Hadley, that helps perfectly! The actual solution, given my former example, would be mapping=aes(x=names(da)[1],y=c) I read about aes_string() sometime, but I didn't realize it was the solution to this problem... As often, PEBKAC! Many Thanks! Martin hadley wickham wrote: > Hi Martin, > >

Re: [R] ggplot2 used in a function - variable scope/environment

2008-02-15 Thread hadley wickham
Hi Martin, Two comments: * ggplot always requires the data to be plotted to be stored in a data.frame, not the environment - this makes it possible to (e.g.) save self contained plot objects - but that isn't the problem here, the problem is setting up the appropriate mapping * aes_string make

[R] ggplot2 used in a function - variable scope/environment

2008-02-15 Thread Martin Rittner
Hi everybody! I'm trying to use ggplot2 to return a plot from a function (so I can add something or alter it then). Unfortunately, if I add a mapping to a layer in the function, the variable *name* is stored in the layer, rather than the variable's *value* - so that after the function returns