Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

add-all-combinations-dk

Add all combinations


Description

Add all combinations of the given rows and columns to the data frames.

Usage

add.all.combinations(data, vars = list(NULL), fill=NA)

Arguments

data

data.frame

vars

variables (list of character vectors)

fill

value to fill structural missings with

Details

This function is used to ensure that we have a matrix of the appropriate dimensionaliy with no missing cells.

Author(s)

Hadley Wickham <h.wickham@gmail.com>

Examples

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")))

reshape

Flexibly Reshape Data

v0.8.8
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.