Skip to content

Instantly share code, notes, and snippets.

@mlt
mlt / table.shingle.R
Last active August 29, 2015 13:58 — forked from MrFlick/table.shingle.R
Update example with origin and legend
table.shingle<-function(..., as.data.frame=F) {
dots<-list(...)
stopifnot(all(sapply(dots, class) %in% c("shingle","factor")))
stopifnot(length(unique(sapply(dots, length)))==1)
dims<-sapply(dots, nlevels)
varnames<-tail(lapply(match.call(), deparse),-1)
varnames["as.data.frame"] <- NULL
res<-array(0, dims, `names<-`(lapply(dots, function(x) as.vector(sapply(levels(x), paste, collapse=":"))), varnames))
isinlevel<-function(z, ints) {
if(is.factor(z)) {