boxplotC: Generates box plots to compare interval-level dependent...

View source: R/boxplotC.r

boxplotCR Documentation

Generates box plots to compare interval-level dependent variable's distribution across categories of independent variable.

Description

Generates box plots for visual comparison of interval-level dependent variable's distribution across categories of independent variable. Includes option for weighting observations, modifying colors, variable widths. Box plot can be used to compare values of interval-level dependent variable by categories of an independent variable (a factor).

Usage

boxplotC(dv, iv, w, data, main, xlab, ylab, box.col, varwidth = TRUE, ivlabs,
  printC = FALSE, ...)

Arguments

dv

Dependent variable, should be in dataset$var form unless dataset specified in optional data argument.

iv

Independent variable, should be in dataset$var form unless dataset specified in optional data argument.

w

(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument.

data

(Optional) Name of dataset that contains dv, iv (and w) variables (optional).

main

(Optional) Supply custom main label for plot; default uses names of dv and iv.

xlab

(Optional) Supply custom x-axis label for plot; default uses name of iv.

ylab

(Optional) Supply y-axis label for plot; default uses name of dv.

box.col

(Optional) The name of color to use for box colors. Default is "gray80".

varwidth

(Optional) Do you want the widths of boxes to be proportional to number of observations in each group? Default is TRUE; set varwidth=FALSE for equal-width boxes.

ivlabs

(Optional) A vector of labels for the iv values that are box lablels.

printC

(Optional) Do you want to print box plot to .html file in working directory? (Default: FALSE)

...

Additional arguments passed to plotting functions, boxplot or bxp.

Value

No return, creates a plot.

RCPA3 Package Tutorial Videos

Textbook References

  • Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 5.

  • Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 53-55. ISBN-13: 978-1506379616; ISBN-10: 150637961.

Online Resources

Examples

  library(RCPA3)
   
  # basic usage with variables as vectors
  boxplotC(dv=nes$ft.rep, iv=nes$partyid3)
  
  # with w and data arguments
  boxplotC(dv=ft.rep, iv=partyid3, w=wt, data=nes)

RCPA3 documentation built on May 29, 2024, 12:19 p.m.

Related to boxplotC in RCPA3...