vignettes/ggtable.Rmd
ggtable.Rmd
library(GGally)
#> Loading required package: ggplot2
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
GGally::ggtable()
The purpose of this function is to quickly plot cross-tabulated tables of discrete variables.
To display tables with the number of observations, simply indicate variables to present in columns and in rows.
The cells
argument allows you to control what to
display. For proportions of the total, row proportions or columns
proportions, simply use "prop"
, "row.prop"
or
"col.prop"
.
Chi-square standardized residuals indicates which cells are over- or underrepresented compared to what would be expected under the independence hypothesis. If the standardized residual is less than -2, the cell’s observed frequency is less than the expected frequency. Greater than 2 and the observed frequency is greater than the expected frequency. Values lower than -3 or higher than 3 indicates a strong effect.
To fill cells with standardized residuals, simply indicate
fill = "std.resid"
.
You can easily indicate weights to take into account with the weight aesthetic.
d <- as.data.frame(Titanic)
ggtable(
d,
"Survived",
c("Age", "Class", "Sex"),
mapping = aes(weight = Freq),
cells = "row.prop",
fill = "std.resid"
)