Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我真的是 plyr 的quoted课;我希望能够组合两个引用对象并获得一个新对象。例如,我如何定义mult(a,b)这样
quoted
mult(a,b)
q1 <- as.quoted("x+y") q2 <- as.quoted("y+z") mult <- function(a, b) {?????} ## mult(q1, q2) returns as.quoted("(x+y)*(y+z)")
您需要eval引用的公式,然后将paste它们放在一起:
eval
paste
mult <- function(a, b) { as.quoted(paste(eval(a), '*', eval(b))) } > mult(q1, q2) List of 1 $ x + y * y + z: language x + y * y + z - attr(*, "env")=<environment: 0x2920980> - attr(*, "class")= chr "quoted" >