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.
您好我正在尝试使用输入变量编写表达式,例如:
a=1 b=-2 bquote(y == .(a)*x+.(b))
结果y == 1 * x + -2 并不y == 1 * x - 2如我所料。
y == 1 * x + -2
y == 1 * x - 2
有没有办法处理它?谢谢!
我不知道优雅的方式,您可以测试符号并返回不同的符号,
pm <- function(x){ if(sign(x) == -1L) return(bquote("-"~.(abs(x)))) else bquote("+"~.(x)) } grid::grid.text(bquote(y== .(a)*x~.(pm(b))))