library(verification)
考虑到几个实验(AA,BB,...,
),我可以使用此reproducible example
按如下方式运行我的代码:
##################### EXPERIMENT AA
#my data in reality is continuous but I convert it to binary using a threshold
obs=data.frame(replicate(10,round(runif(100))))
pred=data.frame(replicate(10,round(runif(100))))
#introduce a few NA values to simulate real world data.
obs1=as.data.frame(lapply(obs, function(cc) cc[ sample(c(TRUE, NA), prob = c(0.85, 0.15), size = length(cc), replace = TRUE) ]))
pred1=as.data.frame(lapply(pred, function(cc) cc[ sample(c(TRUE, NA), prob = c(0.85, 0.15), size = length(cc), replace = TRUE) ]))
#A=mapply(verify,obs1,pred1,frcst.type = "binary", obs.type = "binary")
pred1[,1]=NA # some points in pred1 have all NAs in reality
a=mapply(function(x, y) {if(all(is.na(y))) NA else verify(x, y, frcst.type = "binary", obs.type = "binary")
}, obs1,pred1,SIMPLIFY = F,USE.NAMES = TRUE)
aa=do.call('rbind',a)# put all paramters together and keep rownames for easy identification
##################### EXPERIMENT BB
obs=data.frame(replicate(10,round(runif(100))))
pred=data.frame(replicate(10,round(runif(100))))
#introduce a few NA values to simulate real world data.
obs2=as.data.frame(lapply(obs, function(cc) cc[ sample(c(TRUE, NA), prob = c(0.85, 0.15), size = length(cc), replace = TRUE) ]))
pred2=as.data.frame(lapply(pred, function(cc) cc[ sample(c(TRUE, NA), prob = c(0.85, 0.15), size = length(cc), replace = TRUE) ]))
#A=mapply(verify,obs1,pred1,frcst.type = "binary", obs.type = "binary")
pred2[,1]=NA # some points in pred1 have all NAs in reality
b=mapply(function(x, y) {if(all(is.na(y))) NA else verify(x, y, frcst.type = "binary", obs.type = "binary")
}, obs2,pred2,SIMPLIFY = F,USE.NAMES = TRUE)
bb=do.call('rbind',b)# put all paramters together and keep rownames for easy identification
1)我想强制aa
和bb
强制称为Answer
的数据框忽略$tab, $pred,$obs
。请注意,rownames
和aa
中的bb
是输入数据的colnames
(所有输入都具有相同的名称)
2)对于AA
中的实验BB
,...
,Answer
,我希望两个实验中的每个参数都有相邻的列,例如TS
中的Answer
将TS1
,Ts2
分别代表实验AA和BB。