crosstab: crosstab - outputs a cross table in format data frame >>...

View source: R/to_drop.R

crosstabR Documentation

crosstab - outputs a cross table in format data frame >> Obsolete replaced by epitable

Description

crosstab - outputs a cross table in format data frame >> Obsolete replaced by epitable

Usage

crosstab(data, var1, var2, missing = "always", extra = "None", decimals = 1)

Arguments

data

The data set to look at

var1

Character string, colomn name of the first variable (the rows). Must be a 0/1 (numeric) or No/Yes (character) categorical variable (factors not supported yet).

var2

Character string, colomn name of the second variable (the columns). Must be a 0/1 (numeric) or No/Yes (character) categorical variable (factors not supported yet).

missing

takes auguments 'no' to not show missing and 'always' to show missing (as for table())

extra

What extra info you want. Current options "None", "Total" and "Percent". Default is "None". Feel free to add your own!

decimals

state how many decimal points you want to list for the output of any calculations. Default is 1

Examples

data <- data.frame(id = 1:10,
                   cases = c(rep(1,3), rep(0,7)),
                   vacc = sample(c(0,1), replace = TRUE, size = 10))
table(data$cases, data$vacc, useNA = "always")
crosstab(data, 
         var1 = "cases", 
         var2 = "vacc")
crosstab(data, 
         var1 = "cases", 
         var2 = "vacc", 
         missing = "no")
crosstab(data, 
         var1 = "cases", 
         var2 = "vacc", 
         extra = "Total")
crosstab(data, 
         var1 = "cases", 
         var2 = "vacc", 
         extra = "Percent")


Epiconcept-Paris/STRAP-epiuf documentation built on Aug. 5, 2024, 3:41 a.m.