File: getIntersectList.R

package info (click to toggle)
r-cran-plotrix 3.2-6-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,136 kB
  • sloc: makefile: 3
file content (28 lines) | stat: -rwxr-xr-x 963 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# getIntersectList
# Allows the user to manually enter the number of data objects with each
# combination of intersections of the nelem sets

getIntersectList<-function(nelem,xnames=NULL,sep="-") {
 if(is.null(xnames)) xnames<-LETTERS[1:nelem]
 xnamelen<-length(xnames)
 if(xnamelen < nelem) {
  extranames<-paste("extra",1:(nelem-xnamelen),sep=sep)
  cat("Not enough names in",xnames,"adding",extranames,"\n")
  xnames<-c(xnames,extranames)
 }
 intersectList<-vector("list",nelem+1)
 for(comb in 1:nelem) {
  nn<-choose(nelem,comb)
  intersectList[[comb]]<-rep(0,nn)
  currentnames<-names(intersectList[[comb]])<-
   pasteCols(combn(xnames,comb),sep=sep)
  for(intersect in 1:nn) {
   cat("Number of elements in",currentnames[intersect],"- ")
   intersectList[[comb]][intersect]<-scan(nmax=1,quiet=TRUE)
  }
 }
 cat("Total number of elements - ")
 intersectList[[nelem+1]]<-scan(nmax=1,quiet=TRUE)
 class(intersectList)<-"intersectList"
 return(intersectList)
}