I would like to use the same arguments for several calls to plot
. I tried to use a list (which can serve as a dictionary) :
a <- list(type="o",ylab="")
plot(x,y, a)
But it does not work :
Error in plot.xy(xy, type, ...) : invalid plot type
Any suggestion ?
Extending @baptiste's answer, you can use do.call
like this:
x <- 1:10 # some data
y <- 10:1
do.call("plot", list(x,y, type="o", ylab=""))
Or setting the arguments in a list and call it a
a <- list(x,y, type="o", ylab="")
do.call(plot, a)
Another option is to create a function wrapper:
myplot <- function(...) plot(...,type="o",ylab="")
myplot(x,y)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.