use*_*318 -2 symbols r function
我正在尝试用R编写一个等式(见下面的代码).我想知道如何在我的代码中正确使用+ -之前的sqrt()?
x <- seq(0,1,by=0.01)
y <- %+-%sqrt((.5^2)-(x-.5)^2)+.5
Run Code Online (Sandbox Code Playgroud)
需要单独绘制它们,但%+-%操作符可用于plotmath表达式.然而,需要两个值两侧,因此需要使用非打印phantom():
x <- c( seq(0,1,by=0.01) )
y <- c( sqrt((.5^2)-(x-.5)^2)+.5, -sqrt((.5^2)-(x-.5)^2)+.5)
plot( rep(x,times=2), y)
title(main= bquote( phantom(0) %+-% sqrt((.5^2)-(x-.5)^2)+.5))
Run Code Online (Sandbox Code Playgroud)