How to combine do.call() plot() and [removed])

前端 未结 3 869
滥情空心
滥情空心 2021-02-19 19:50

I am getting an error when I try and combine using expression with do.call and plot.

 x <- 1:10
 y <- x^1.5
         


        
相关标签:
3条回答
  • 2021-02-19 20:24

    You can use alist rather then list

    p <- alist(xlab=expression(paste("Concentration (",mu,"M)")))
    do.call(plot,c(y~x,p))
    
    0 讨论(0)
  • 2021-02-19 20:34

    Setting quote=TRUE also works. It in effect prevents do.call() from evaluating the elements of args before it passes them to the function given by what.

    x <- 1:10
    y <- x^1.5
    p <- list(xlab=expression(paste("Concentration (",mu,"M)",sep="")))
    
    do.call(what = "plot", args = c(y ~ x, p), quote = TRUE)
    
    0 讨论(0)
  • 2021-02-19 20:35

    do.call evaluates the parameters before running the function; try wrapping the expression in quote:

    p <- list(xlab=quote(expression(paste("Concentration (",mu,"M)"))))
    do.call("plot", c(y~x, p))
    
    0 讨论(0)
提交回复
热议问题