splitInteractions {biology} | R Documentation |
~~ A concise (1-5 lines) description of what the function does. ~~
splitInteractions(split, factors, names, asgn, df.names)
split |
~~Describe split here~~ |
factors |
~~Describe factors here~~ |
names |
~~Describe names here~~ |
asgn |
~~Describe asgn here~~ |
df.names |
~~Describe df.names here~~ |
~~ If necessary, more details than the description above ~~
~Describe the value returned If it is a LIST, use
comp1 |
Description of 'comp1' |
comp2 |
Description of 'comp2' |
...
....
~~further notes~~
~Make other sections like Warning with section{Warning }{....} ~
~~who you are~~
~put references to the literature/web site here ~
~~objects to See Also as help
, ~~~
##---- Should be DIRECTLY executable !! ---- ##-- ==> Define data, use random, ##-- or do help(data=index) for the standard data sets. ## The function is currently defined as function (split, factors, names, asgn, df.names) { ns <- names(split) for (i in unique(asgn)) { if (i == 0 || names[i + 1] %in% ns) next f <- rownames(factors)[factors[, i] > 0] sp <- f %in% ns if (any(sp)) { if (sum(sp) > 1) { old <- split[f[sp]] nn <- f[sp] names(nn) <- nn marg <- lapply(nn, function(x) df.names[asgn == (match(x, names) - 1)]) term.coefs <- strsplit(df.names[asgn == i], ":", fixed = TRUE) ttc <- sapply(term.coefs, function(x) x[sp]) rownames(ttc) <- nn splitnames <- apply(expand.grid(lapply(old, names)), 1, function(x) paste(x, collapse = ".")) names(splitnames) <- splitnames tmp <- sapply(nn, function(i) names(old[[i]])[match(ttc[i, ], marg[[i]])]) tmp <- apply(tmp, 1, function(x) paste(x, collapse = ".")) new <- lapply(splitnames, function(x) match(x, tmp)) split[[names[i + 1]]] <- new[sapply(new, function(x) length(x) > 0)] } else { old <- split[[f[sp]]] marg.coefs <- df.names[asgn == (match(f[sp], names) - 1)] term.coefs <- strsplit(df.names[asgn == i], ":", fixed = TRUE) ttc <- sapply(term.coefs, function(x) x[sp]) new <- lapply(old, function(x) seq(along = ttc)[ttc %in% marg.coefs[x]]) split[[names[i + 1]]] <- new } } } split }