Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(tidyverse)
- xVals <- function(n, center, width) {
- seq(from = center - width, to = center + width, length.out = n)
- }
- width <- 0.3
- survey <- tigerstats::m111survey
- gms <-
- survey %>%
- group_by(seat) %>%
- summarize(groupMean = mean(fastest), n = n()) %>%
- mutate(grpNumber = as.numeric(seat)) %>%
- mutate(xStart = grpNumber - width,
- xEnd = grpNumber + width)
- xs <- c(xVals(gms$n[1], 1, width),
- xVals(gms$n[2], 2, width),
- xVals(gms$n[3], 3, width))
- survey <-
- survey %>%
- inner_join(gms, by = "seat") %>%
- mutate(grandMean = mean(fastest)) %>%
- arrange(seat) %>%
- mutate(xs = xs)
- # SSE
- ggplot(survey, aes(x = xs, y = fastest)) +
- geom_point() +
- geom_segment(aes(x = xs, y = fastest, xend = xs, yend = groupMean)) +
- geom_segment(gms,
- mapping = aes(x = xStart, xend = xEnd, y = groupMean, yend = groupMean))
Add Comment
Please, Sign In to add comment