boxplotC | R Documentation |
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).
boxplotC(dv, iv, w, data, main, xlab, ylab, box.col, varwidth = TRUE, ivlabs,
printC = FALSE, ...)
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 |
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, |
No return, creates a plot.
Making Box Plots with RCPA3's boxplotC Function 15:12, shows you how to use the RCPA3 Package's boxplotC function to create box plots that show the relationship between an interval-level dependent variables and a categorical independent variable.
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
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.
R Tutorials & Resources for Graphing Relationships and Describing Patterns, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site, find datasets for your own research and resources to help with political analysis.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.