Skip to content

Instantly share code, notes, and snippets.

@expersso
Last active December 6, 2015 17:15
Show Gist options
  • Save expersso/e69ee0ebb4f214dbe544 to your computer and use it in GitHub Desktop.
Save expersso/e69ee0ebb4f214dbe544 to your computer and use it in GitHub Desktop.
Length of names of months and weekdays
library(lubridate)
library(ggplot2)
period_name <- c(month.name, as.character(wday(1:7, label = TRUE, abbr = FALSE)))
name_length <- sapply(strsplit(period_name, ""), length)
df <- data.frame(period_name, name_length, period_order = c(1:12, 1:7),
type = rep(c("Months", "Weekdays"), c(12, 7)))
ggplot(df, aes(x = period_order, y = name_length, label = period_name)) +
geom_smooth(se = FALSE) +
geom_text(size = 3, hjust = "inward", position = "jitter") +
facet_wrap(~type, scales = "free") +
theme_bw() +
scale_x_continuous(breaks = 1:12) +
labs(x = "\nPeriod order", y = "# of characters in name\n",
title = "Length of names of months and weekdays\n")
@expersso
Copy link
Author

expersso commented Dec 6, 2015

rplot

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