Skip to content

Instantly share code, notes, and snippets.

@benmarwick
Created July 12, 2018 17:13
Show Gist options
  • Save benmarwick/379ccf62348ff57fb5782e18534e2c65 to your computer and use it in GitHub Desktop.
Save benmarwick/379ccf62348ff57fb5782e18534e2c65 to your computer and use it in GitHub Desktop.
Writing session productivity
library("googlesheets")
suppressPackageStartupMessages(library("dplyr"))
third_party_gap <- "https://docs.google.com/spreadsheets/d/1xbMp7UZ7Nusjb2u1b1RihZrNzPMINZ8BHy9x2urGTzo/edit#gid=0" %>%
gs_url()
wp <-
third_party_gap %>%
gs_read(ws = "Writing progress")
wp %<>%
mutate(duration = as.numeric((`end time` - `start time`)/60/60 )) %>%
mutate(wph = `Words written` / duration)
# Relationship between the length of the writing session and the words written per hour
library(ggplot2)
ggplot(wp,
aes(duration,
wph)) +
geom_point() +
geom_smooth()
# seems that a 2 h mark is a breakpoint
# Relationship between the total number of words written in a session and the words written per hour
ggplot(wp,
aes(`Words written`,
wph)) +
geom_point() +
geom_smooth()
# this looks a bit complex
ggplot(wp,
aes(`Words written`)) +
geom_histogram()
# lets put the sessions into groups by the amount of words written
wp <-
wp %>%
mutate(group = case_when(
`Words written` > 100 & `Words written` < 170 ~ "100 words",
`Words written` > 190 & `Words written` < 250 ~ "200 words",
`Words written` > 270 & `Words written` < 350 ~ "300 words",
))
# what group has the highest words per hour?
ggplot(wp,
aes(group,
wph)) +
geom_boxplot()
# the 200 word group has the highest, and the 300 word has the lowest
@benmarwick
Copy link
Author

image

image

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment