R-graphics are great for exploring data, as it often has very smart defaults. For example, when building with a formula, labels for the graph axes are inferred from the formula. In other words, the following two calls produce the same output:
plot(x~y) plot(x~y, xlab="x", ylab="y")
Is there a way to get a similar “smart startup”?
For example, I would like to name
plot(x~y, main=<something>)
And create the same output as the call
plot(x~y, main="plot(x~y)")
If <something> inserts a call used by some introspection.
Is there a way to do this in R, either through some standard mechanism or an external package?
edit: One suggestion was to specify the formula as a string and provide it as an argument to call formula() , as well as main . This is useful, but it skips parameters that can affect the graph, for example, using subsets of data. To clarify, I would like
x<-c(1,2,3) y<-c(1,2,3) z<-c(0,0,1) d<-data.frame(x,y,z) plot(x~y, subset(d, z==0), main=<something>)
To have the same effect as
plot(x~y, subset(d, z==0), main="plot(x~y, subset(d, z==0))")