Intro Thoughts

Status Quo

library(tidyverse)

df <- data.frame(
  trt = factor(c(1, 1, 2, 2)),
  resp = c(1, 5, 3, 4),
  group = factor(c(1, 2, 1, 2)),
  upper = c(1.1, 5.3, 3.3, 4.2),
  lower = c(0.8, 4.6, 2.4, 3.6)
)

p <- ggplot(df, aes(trt, resp, colour = group))
p + geom_linerange(aes(ymin = lower, ymax = upper))

p + geom_pointrange(aes(ymin = lower, ymax = upper))

p + geom_crossbar(aes(ymin = lower, ymax = upper), width = 0.2)

p + geom_errorbar(aes(ymin = lower, ymax = upper), width = 0.2)

ggplot(cars, aes(speed, dist, xend = lag(speed), 
                 yend = lag(dist))) + 
  geom_segment(arrow = arrow(angle = 90, 
                             ends = "both"))
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_segment()`).

GeomSegment$default_aes
## Aesthetic mapping: 
## * `colour`    -> "black"
## * `linewidth` -> 0.5
## * `linetype`  -> 1
## * `alpha`     -> NA
geom_segment2 <- function(arrow2 = arrow(angle = 90, 
                             ends = "both", length = unit(2, "mm"))){
  
    geom_segment(arrow = arrow2)
  
}

ggplot(cars, aes(speed, dist, 
                 xend = lag(speed), 
                 yend = lag(dist))) + 
  geom_segment2()
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_segment()`).

Experiment

Closing remarks, Other Relevant Work, Caveats