This function tries to choose a good plot to show for comparing two variables at a time.

plot_twoway(x, y, xvar, yvar, color = "lightblue", pal = "Set1")

Arguments

x

A vector.

y

A vector of the same length as `x`.

xvar

The name of the x variable.

yvar

The name of the y variable.

color

A color to use in the plots that have one single color.

pal

A color palette to use with brewer.pal for the mosaic plots when `x` and `y` are factors.

Value

A plot of `x` versus `y`.

Author

Leonardo Collado-Torres

Examples

plot_twoway(as.factor(mtcars$gear), mtcars$mpg, xvar = "gear", yvar = "mpg")