Hallo, I modified a code given by Andrija, a contributor in the list to achieve two objectives: create 1000 samples from a list of 207 samples with each of the samples cointaining 20 good and 20 bad. THis i have achievedcalcuate AUC each of the 1000 samples, this i get an error. Please see the code below and assist me.
> data<-data.frame(id=1:(165+42),main_samp$SCORE, > x=rep(c("BAD","GOOD"),c(42,165))) > f<-function(x) { + str.sample<-list() + for (i in 1:length(levels(x$x))) + { + str.sample[[i]]<-x[x$x==levels(x$x)[i] ,][sample(tapply(x$x,x$x,length)[i],20,rep=T),] + } + strat.sample<-do.call("rbind",str.sample) + return(strat.sample$main_samp.SCORE) + } > f(data) [1] 706 633 443 843 756 743 730 843 706 730 606 743 768 768 743 763 608 730 743 743 530 813 813 831 793 900 793 693 900 738 706 831 [33] 818 758 718 831 768 638 770 738 > repl<-list() > auc<-list() > for(i in 1:1000) + { + repl[[i]]<-f(data) + auc[[i]]<-colAUC(repl[[i]],rep(c("BAD","GOOD")),plotROC=FALSE,alg="ROC") + } Error in colAUC(repl[[i]], rep(c("BAD", "GOOD")), plotROC = FALSE, alg = "ROC") : colAUC: length(y) and nrow(X) must be the same Thanks alotTaby [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.