mat <- matrix(rep(8,150), ncol=15, dimnames=list(NULL,
paste0(rep(LETTERS[4:2],each=6),1:6)[c(1:5,7:16)]))
mat[lower.tri(mat)] <- NA
mat[,15] <- NA
mat[c(2:3,9),14:15] <- NA
mat[c(1,10),13:15] <- NA
mat
presenceFilt(mat, substr(colnames(mat),1,1))
# custom 2 groups
presenceFilt(mat, rep(1:2,c(9,6))) # D1- C4, C5 - B4
# one more example
dat1 <- matrix(1:56, ncol=7)
dat1[c(2:6,10,12,18,19,20,22,23,26:28,30,31,34,38,39,50,54)] <- NA
grp3 <- letters[c(3,3,2,2,1,1,1)]
colnames(dat1) <- correctToUnique(grp3, sep="")
dat1
## At least one group wo any NAs
presenceFilt(dat1, grp3, maxGr=0)
presenceFilt(dat1, gr=gl(2,4)[-1], maxGr=1, ratM=0.1)
presenceFilt(dat1, gr=gl(2,4)[-1], maxGr=2, rat=0.5)
Run the code above in your browser using DataLab