r:使用mapply函数来创建两个列表
我有两张单子和两张表。样本数据如下: dd1: dd2: 我想将r:使用mapply函数来创建两个列表,r,mapply,R,Mapply,我有两张单子和两张表。样本数据如下: dd1: dd2: 我想将ROC函数应用于两个列表中的五个向量,例如,我可以对每个向量使用ROC函数,它可以工作 library(pROC) roc1<-roc(as.factor(unlist(dd2$`1`)), dd1$`1`) roc2<-roc(as.factor(unlist(dd2$`2`)), dd1$`2`) roc3<-roc(as.factor(unlist(dd2$`3`)), dd1
ROC
函数应用于两个列表中的五个向量
,例如,我可以对每个向量
使用ROC
函数,它可以工作
library(pROC)
roc1<-roc(as.factor(unlist(dd2$`1`)), dd1$`1`)
roc2<-roc(as.factor(unlist(dd2$`2`)), dd1$`2`)
roc3<-roc(as.factor(unlist(dd2$`3`)), dd1$`3`)
roc4<-roc(as.factor(unlist(dd2$`4`)), dd1$`4`)
roc5<-roc(as.factor(unlist(dd2$`5`)), dd1$`5`)
它不起作用。谁能告诉我怎么修吗
(请单击链接dd1和dd2以获取数据)请包含示例数据,而不是将我们指向dropbox站点。链接甚至不起作用。数据包含很多元素。好的,我改为添加示例数据。@lebelinoz实际上链接是有效的,你不能预览,但你可以不登录下载。@lebelinoz我添加了一些数据示例,你能帮我检查一下代码吗?请使用dput()
给出数据示例。请包含示例数据,而不是将我们指向dropbox站点。链接甚至不起作用。数据包含很多元素。好的,我改为添加示例数据。@lebelinoz实际上链接有效,您不能预览,但您可以不登录下载。@lebelinoz我添加了一些数据示例,您能帮我检查一下代码吗?请使用dput()
给出数据示例。
> dd2
$`1`
[1] 1 0 0 1 1 0
$`2`
[1] 1 0 1 1 0 0
$`3`
[1] 1 0 0 1 0 0
$`4`
[1] 0 1 0 0 0 0
$`5`
[1] 0 1 0 1 0 0
library(pROC)
roc1<-roc(as.factor(unlist(dd2$`1`)), dd1$`1`)
roc2<-roc(as.factor(unlist(dd2$`2`)), dd1$`2`)
roc3<-roc(as.factor(unlist(dd2$`3`)), dd1$`3`)
roc4<-roc(as.factor(unlist(dd2$`4`)), dd1$`4`)
roc5<-roc(as.factor(unlist(dd2$`5`)), dd1$`5`)
mapply(function(x,y) roc(as.factor(unlist(x)),y), dd2, dd1)