Skip to content
Prev 172767 / 398506 Next

Using vectors of names in calls for functions

Hi Pascal,

You need the aes_string function:

V1_P2_plot<-function(df, x, y, z) {
   ggplot(df, aes_string(x = x, y= y, fill = z)) +
    geom_tile()
}
j<-c("k", "l")
i<-"m"
m<-rnorm(25)
vsim<-cbind(expand.grid(k=1:5, l=1:5*10), m)

V1_P2_plot(df=vsim, x=j[1], y=j[2], z=i)

Hadley
On Thu, Mar 5, 2009 at 3:16 PM, Pascal Boisson <hoothootprod at gmail.com> wrote: