cdfCompare中的错误,对象';离散';找不到
我正在为一个数据框中的2列数据绘制2个累积分布图。我的代码是:cdfCompare中的错误,对象';离散';找不到,r,cdf,R,Cdf,我正在为一个数据框中的2列数据绘制2个累积分布图。我的代码是: library(EnvStats) cdfCompare(Ratio1,Ratio2 discrete = FALSE, prob.method = ifelse(discrete, "emp.probs", "plot.pos"), plot.pos.con = NULL, distribution = "norm", pa
library(EnvStats)
cdfCompare(Ratio1,Ratio2 discrete = FALSE,
prob.method = ifelse(discrete, "emp.probs", "plot.pos"), plot.pos.con = NULL,
distribution = "norm", param.list = NULL,
estimate.params = is.null(param.list), est.arg.list = NULL,
x.col = "blue", y.or.fitted.col = "black",
x.lwd = 3 * par("cex"), y.or.fitted.lwd = 3 * par("cex"),
x.lty = 1, y.or.fitted.lty = 2, digits = .Options$digits,
type = ifelse(discrete, "s", "l"), main = NULL, xlab = NULL, ylab = NULL,
xlim = NULL, ylim = NULL)
当我运行此代码时,生成了一个错误:
Error in ifelse(discrete, "emp.probs", "plot.pos") :
object 'discrete' not found
当我使用较短的代码时:
cdfCompare(Ratio1,Ratio2 discrete = FALSE)
没有错误。我还试着设置
离散=真
,看起来它不会影响打印的形状(不平滑,我有大约170000个值)。非常感谢。您可以定义一个单独的变量来传递离散值,并使用
if
/else
来选择问题方法
discrete_value <- FALSE
cdfCompare(Ratio1,Ratio2 discrete = discrete_value,
prob.method = if(discrete_value) "emp.probs" else "plot.pos", plot.pos.con = NULL,
distribution = "norm", param.list = NULL,
estimate.params = is.null(param.list), est.arg.list = NULL,
x.col = "blue", y.or.fitted.col = "black",
x.lwd = 3 * par("cex"), y.or.fitted.lwd = 3 * par("cex"),
x.lty = 1, y.or.fitted.lty = 2, digits = .Options$digits,
type = ifelse(discrete, "s", "l"), main = NULL, xlab = NULL, ylab = NULL,
xlim = NULL, ylim = NULL)
discrete\u值ifelse
正在尝试查找名为discrete
的对象,它无法用于测试函数参数discrete
是否按您编写的方式设置为TRUE
。谢谢。这是可行的。只需将:type=ifelse(离散的,“s”,“l”)更改为type=ifelse(离散的值,“s”,“l”)