add.all.combinations | R Documentation |
Add all combinations of the given rows and columns to the data frames.
add.all.combinations(data, vars = list(NULL), fill=NA)
data |
data.frame |
vars |
variables (list of character vectors) |
fill |
value to fill structural missings with |
This function is used to ensure that we have a matrix of the appropriate dimensionaliy with no missing cells.
Hadley Wickham <h.wickham@gmail.com>
rdunif <- function(n=20, min=0, max=10) floor(runif(n,min, max)) df <- data.frame(a = rdunif(), b = rdunif(),c = rdunif(), result=1:20) add.all.combinations(df) add.all.combinations(df, list("a", "b")) add.all.combinations(df, list("a", "b"), fill=0) add.all.combinations(df, list(c("a", "b"))) add.all.combinations(df, list("a", "b", "c")) add.all.combinations(df, list(c("a", "b"), "c")) add.all.combinations(df, list(c("a", "b", "c")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.