niceBinscatter: Binscatter

Description Usage Arguments Details Value Examples

View source: R/nicePlots.R

Description

Group variable on the horizontal axis into equal-sized bins and calculate group means for each bin.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
niceBinscatter(
  data,
  x,
  y,
  color = NULL,
  type = "pointrange",
  bins = 20,
  xlims = NULL,
  ylims = NULL,
  title = "",
  xlab = x,
  ylab = y,
  colorname = color,
  colorlabels = NULL,
  legendpos = "right"
)

Arguments

data

A dataset

x

horizontal axis variable

y

vertical axis variable

color

Character. Variables to group on. With changing color

type

Type of geom to plot ("point" (default), "pointrange", "line")

bins

Numeric. Number of bins (default: 20)

xlims, ylims

Numeric vectors of 2 elements. Axis limits

title

Plot title

xlab, ylab

Axis labels

colorname

Optional variable names for groups to be displayed on legend

colorlabels

Optional labels for grouos to be displayed on legend

legendpos

Legend position. Options: “left”,“top”, “right” (default), “bottom”

Details

Backend code source: https://github.com/maximilianeber/binscatter (Maximilian Eber)

Value

A ggplot2-plot

Examples

1
niceBinscatter(ggplot2::mpg, "displ", "hwy", color = "class", type = "pointrange")

SZuzek/nicePlots documentation built on Dec. 18, 2021, 12:01 p.m.