在 cutpointr (R) 中设置两个手动切割点?

问题描述

我已经在 R 中下载了 cutpointr 包并想使用 oc_manual(来自文献的切点),但需要根据另一个变量(可以取 0 或 1 的值)设置两个手动输出点。我在做这件事时遇到了一些困难。每当我尝试添加 ifelse 语句或分层时,R 都会运行各种错误。有什么办法解决这个问题?提前致谢!

示例:

mtcars
library(cutpointr)
data(mtcars)
opt_cut_manual <- cutpointr(mtcars,mpg,vs,method = oc_manual,cutpoint = 20,boot_runs = 1000)
plot(opt_cut_manual)

我只能设置一个手动切割点,当我想将 am=0 时的切割点设置为 20,而 am=1 时将其设置为 25。我尝试使用 ifelse 语句:

mtcars
library(cutpointr)
data(mtcars)
opt_cut_manual <- cutpointr(mtcars,if (am==0) {
  cutpoint = 20
} else {
  cutpoint =25
},boot_runs = 1000)
plot(opt_cut_manual)

这是我得到的错误

错误:无法将调用转换为字符串 另外: 警告信息: 在 if (!(deparse(substitute(subgroup)) == "NULL")) { : 条件的长度 > 1 并且只使用第一个元素

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)