scatter_45: Standard scatterplot with 45 degree line

View source: R/visualize.R

scatter_45R Documentation

Standard scatterplot with 45 degree line

Description

Standard scatterplot with 45 degree line

Usage

scatter_45(
  tbl,
  xvar,
  yvar,
  lblvar = NULL,
  xlab = NULL,
  ylab = NULL,
  xlim = NULL,
  ylim = NULL,
  size.point = 0.8,
  size.text = 2,
  size.errorstat = 2,
  percent = TRUE,
  pct_accuracy = 1,
  ubvar = NULL,
  lbvar = NULL,
  colvar = NULL,
  alpha.CI = 0.75,
  alpha.point = 0.8,
  alpha.text = 0.5,
  alpha.segment = 0.5,
  max.overlaps = 20,
  repeat.axis.text = FALSE,
  by_form = NULL,
  by_nrow = NULL,
  by_labels = NULL,
  show_error = "rmse",
  expand_axes = TRUE,
  ...
)

Arguments

tbl

dataset of summary statistics. Each row must represent a point. Statistics of each point, like the point estimate, 5% quantile, etc.., must be in columns.

xvar

Variable to put on x-axis, unquoted

yvar

Variable to put on y-axis, unquoted

lblvar

Variable to use as labels for geom_text_repel, unquoted

xlab, ylab

x and y-axis labels, respectively

xlim, ylim

x and y-axis limits, respectively

size.point

Size of points to use in ggplot

size.text

Size for the labels

size.errorstat

Size for the error statistic

percent

Are axis values in percent? Defaults to TRUE

pct_accuracy

If using percents on axes, what is the accuracy. Defaults to 1, which displays whole numbers

ubvar, lbvar

Variable to use as upper and lower bounds for geom_errorbar, unqoted

colvar

Variable to use as colors, unquoted

alpha.point, alpha.CI, alpha.text

The transparency value for the points (.point), intervals (.CI), and text labels (.text).s

alpha.segment

The transparency value for the segments linking the labels to the points, ranging from 0 to 1.

max.overlaps

To be passed on to geom_text_repel if a label is used.

repeat.axis.text

Whether to reproduce the axis texts for every facets in facet_rep_wrap(). Defaults to FALSE

by_form

If the dataset is in long form with separate rows for different model estimates, you can supply a formula to be passed on to facet_rep_wrap() to have separate facets for each model.

by_nrow

If using facets, how many rows should the facet take? Defaults to NULL, which is facet_wrap's default

by_labels

A named vector for the facets, where the names are the names of the unique values of the variable by specified in by_form (e.g. "model") and the values are the corresponding characters to recode to.

show_error

Which error(s) to show if any. Currently supports c("rmse", "mean, "bias", "corr"). NULL for now display.

expand_axes

Whether to expand the axes so that the plot is a square, even if there is more whitespace. Overrides xlim and ylim.

...

Additional arguments sent to the error_lbl function

Examples

library(dplyr)
library(ccesMRPrun)

mrp_df <- summ_sims(poststrat_draws(fit_GA, poststrat_tgt = acs_GA)) %>%
  left_join(elec_GA)


scatter_45(mrp_df,
           clinton_vote,
           p_mrp_est,
           lblvar = cd,
           lbvar = p_mrp_050,
           ubvar = p_mrp_950,
           xlab = "Clinton Vote",
           ylab = "MRP Estimate")



kuriwaki/ccesMRPviz documentation built on May 12, 2022, 11:50 p.m.