View source: R/counts_to_cases.R
counts_to_cases | R Documentation |
converts a contingency table or a data frame of counts into a data frame of individual observations.
counts_to_cases(x, count.col = "Freq")
x |
a contingency table or a data frame |
count.col |
the name of the column containing the counts. Default is "Freq". |
a data frame of cases
# Create a cross-tabulation demo data #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% xtab <- as.table( rbind(c(20, 5), c(16,9)) ) dimnames(xtab) <- list( before = c("non.smoker", "smoker"), after = c("non.smoker", "smoker") ) xtab # Convert into a data frame of cases #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% df <- counts_to_cases(xtab) head(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.