Dear all: I have six vector from six DIF detection results. as below:> difMH[[100]]$DIFitems[1] 1 9 19 21 22 24 25 27 29 30 34 38 40> difMH[[90]]$DIFitems[1] 1 2 9 14 18 19 21 22 25 28 30 34 38 39> difMH[[80]]$DIFitems[1] 1 8 9 19 21 22 24 25 26 28 30 34 38> difMH[[70]]$DIFitems[1] 1 8 9 10 16 18 21 22 25 28 30 32 34 38 39> difMH[[60]]$DIFitems[1] 1 9 19 21 22 23 25 27 30 34 36 38 39> difMH[[50]]$DIFitems[1] 1 9 10 11 17 18 21 22 23 25 28 30 34 38 39 I have two questions. first, how to combine these to a matrix? second, how to compare them with "1 9 21 22 25 30 34 38" how much units hit? how much units are false-alarm? thanks!
Hello, Try the following. # 1. idx <- seq(50, 100, by = 10) mat <- matrix(difMH[idx]$DIFitems, ncol = length(idx)) # 2. comp <- c(1, 9, 21, 22, 25, 30, 34, 38) hit <- lapply(difMH[idx], function(x) length(intersect(x$DIFitems, comp))) falarm <- lapply(difMH[idx], function(x) length(setdiff(x$DIFitems, comp))) Hope this helps, Rui Barradas Em 26-12-2012 12:37, Yung Chih Ou escreveu:> Dear all: > > I have six vector from six DIF detection results. > as below: >> difMH[[100]]$DIFitems > [1] 1 9 19 21 22 24 25 27 29 30 34 38 40 >> difMH[[90]]$DIFitems > [1] 1 2 9 14 18 19 21 22 25 28 30 34 38 39 >> difMH[[80]]$DIFitems > [1] 1 8 9 19 21 22 24 25 26 28 30 34 38 >> difMH[[70]]$DIFitems > [1] 1 8 9 10 16 18 21 22 25 28 30 32 34 38 39 >> difMH[[60]]$DIFitems > [1] 1 9 19 21 22 23 25 27 30 34 36 38 39 >> difMH[[50]]$DIFitems > [1] 1 9 10 11 17 18 21 22 23 25 28 30 34 38 39 > > I have two questions. > > first, how to combine these to a matrix? > > second, how to compare them with "1 9 21 22 25 30 34 38" > how much units hit? > how much units are false-alarm? > > thanks! > > ______________________________________________ > R-help at 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.
Hello, Sorry, my previous post is wrong, to make of it a matrix use do.call(cbind, lapply(idx, function(i) difMH[[i]]$DIFitems)) Hope this helps, Rui Barradas Em 26-12-2012 14:44, Rui Barradas escreveu:> Hello, > > Try the following. > > # 1. > idx <- seq(50, 100, by = 10) > mat <- matrix(difMH[idx]$DIFitems, ncol = length(idx)) > > # 2. > comp <- c(1, 9, 21, 22, 25, 30, 34, 38) > hit <- lapply(difMH[idx], function(x) length(intersect(x$DIFitems, > comp))) > falarm <- lapply(difMH[idx], function(x) length(setdiff(x$DIFitems, > comp))) > > > Hope this helps, > > Rui Barradas > Em 26-12-2012 12:37, Yung Chih Ou escreveu: >> Dear all: >> >> I have six vector from six DIF detection results. >> as below: >>> difMH[[100]]$DIFitems >> [1] 1 9 19 21 22 24 25 27 29 30 34 38 40 >>> difMH[[90]]$DIFitems >> [1] 1 2 9 14 18 19 21 22 25 28 30 34 38 39 >>> difMH[[80]]$DIFitems >> [1] 1 8 9 19 21 22 24 25 26 28 30 34 38 >>> difMH[[70]]$DIFitems >> [1] 1 8 9 10 16 18 21 22 25 28 30 32 34 38 39 >>> difMH[[60]]$DIFitems >> [1] 1 9 19 21 22 23 25 27 30 34 36 38 39 >>> difMH[[50]]$DIFitems >> [1] 1 9 10 11 17 18 21 22 23 25 28 30 34 38 39 >> >> I have two questions. >> >> first, how to combine these to a matrix? >> >> second, how to compare them with "1 9 21 22 25 30 34 38" >> how much units hit? >> how much units are false-alarm? >> >> thanks! >> >> ______________________________________________ >> R-help at 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. > > ______________________________________________ > R-help at 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.
Hi, Assuming the data structure is similar to this example: ?difMH<-list(c(1,9,19,21,22,24,25,27,29,30,34,38,40),c(1,2,9,14,18,19,21,22,25,28,30,34,38,39),c(1,8,9,19,21,22,24,25,26,28,30,34,38),c(1,8,9,10,16,18,21,22,25,28,30,32,34,38,39),c(1,9,19,21,22,23,25,27,30,34,36,38,39),c(1,9,10,11,17,18,21,22,23,25,28,34,38,39)) names(difMH)<-c(100,90,80,70,60,50) ?difMH<-lapply(difMH,function(x) data.frame(DIFitems=x,newcol=seq_along(x))) res1<-sapply(difMH,`[`,1) res2<-t(sapply(res1,`[`,1:max(sapply(res1,length)))) ?res2 #???????????? [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] #100.DIFitems??? 1??? 9?? 19?? 21?? 22?? 24?? 25?? 27?? 29??? 30??? 34??? 38 #90.DIFitems???? 1??? 2??? 9?? 14?? 18?? 19?? 21?? 22?? 25??? 28??? 30??? 34 #80.DIFitems???? 1??? 8??? 9?? 19?? 21?? 22?? 24?? 25?? 26??? 28??? 30??? 34 #70.DIFitems???? 1??? 8??? 9?? 10?? 16?? 18?? 21?? 22?? 25??? 28??? 30??? 32 #60.DIFitems???? 1??? 9?? 19?? 21?? 22?? 23?? 25?? 27?? 30??? 34??? 36??? 38 #50.DIFitems???? 1??? 9?? 10?? 11?? 17?? 18?? 21?? 22?? 23??? 25??? 28??? 34 ? # ????????? [,13] [,14] [,15] #100.DIFitems??? 40??? NA??? NA #90.DIFitems???? 38??? 39??? NA #80.DIFitems???? 38??? NA??? NA #70.DIFitems???? 34??? 38??? 39 #60.DIFitems???? 39??? NA??? NA #50.DIFitems???? 38??? 39??? NA ?is.matrix(res2) #[1] TRUE #For the second part, similar to Rui's solution: hit<- do.call(rbind,lapply(res1,function(x) length(intersect(x,comp)))) flarm<- do.call(rbind,lapply(res1,function(x) length(setdiff(x,comp)))) A.K. ----- Original Message ----- From: Yung Chih Ou <chihchihou at gmail.com> To: r-help <r-help at r-project.org> Cc: Sent: Wednesday, December 26, 2012 7:37 AM Subject: [R] data comparison Dear all: I have six vector from six DIF detection results. as below:> difMH[[100]]$DIFitems[1]? 1? 9 19 21 22 24 25 27 29 30 34 38 40> difMH[[90]]$DIFitems[1]? 1? 2? 9 14 18 19 21 22 25 28 30 34 38 39> difMH[[80]]$DIFitems[1]? 1? 8? 9 19 21 22 24 25 26 28 30 34 38> difMH[[70]]$DIFitems[1]? 1? 8? 9 10 16 18 21 22 25 28 30 32 34 38 39> difMH[[60]]$DIFitems[1]? 1? 9 19 21 22 23 25 27 30 34 36 38 39> difMH[[50]]$DIFitems[1]? 1? 9 10 11 17 18 21 22 23 25 28 30 34 38 39 I have two questions. first, how to combine these to a matrix? second, how to compare them with "1 9 21 22 25 30 34 38" how much units hit? how much units are false-alarm? thanks! ______________________________________________ R-help at 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.
Seemingly Similar Threads
- the R session had a fatal problem.
- [LLVMdev] MachineRegisterInfo use_iterator/reg_iterator?
- [LLVMdev] Custom pass that runs before EmitStartOfAsmFile()?
- [LLVMdev] MachineRegisterInfo use_iterator/reg_iterator?
- [LLVMdev] Default/initial values for function arguments?