# NOT RUN {
# Calling on two vectors:
a <- c("hi", "hi", "lo", "lo")
b <- c(1, 2, 2, 2)
crosstab(a, b)
crosstab(mtcars$cyl, mtcars$gear)
crosstab(mtcars$cyl, mtcars$gear, "row")
# Passing in a data.frame using a pipeline:
mtcars %>% crosstab(cyl, gear)
mtcars %>% crosstab(cyl, gear, "row")
# This allows for upstream operations
# prior to the crosstab() call:
library(dplyr)
mtcars %>%
filter(am == 0) %>%
crosstab(cyl, gear)
# }
Run the code above in your browser using DataLab