Skip to content

Instantly share code, notes, and snippets.

@arvi1000
Last active May 1, 2020 21:46
Show Gist options
  • Save arvi1000/2f6c10efa50b7a6cae507a2519e2b55b to your computer and use it in GitHub Desktop.
Save arvi1000/2f6c10efa50b7a6cae507a2519e2b55b to your computer and use it in GitHub Desktop.
library(tidyverse)
# data ----
"JonPear6 10:21 AM
1 8 9
plättyjö:plattyjo: 10:22 AM
3 1 8
swirving 10:22 AM
12, 1, 6
rrrrrrrrrr:palm_tree: 10:23 AM
6, 5, 12
Alan 10:25 AM
7 4 2
John 11:22 AM
12 14 9 5 2 11
The_Meat:speech_balloon: 12:09 PM
12, 7, 5, 9, 3
Benjamin 12:23 PM
2, 5, 1, 6, 7
Adem 1:13 PM
1 3 14
geojoek:bike: 1:20 PM
1 6" %>%
strsplit('\n+') %>%
unlist -> dat
# parse ----
dat <- dat %>%
matrix(ncol=2, byrow = T) %>%
`colnames<-`(c('name', 'choices')) %>%
as_tibble()
dat$name <- gsub('( |\\:).*M$', '', dat$name)
clean_dat <- lapply(1:nrow(dat), function(x) {
tibble(name = dat$name[x],
choices =
dat$choices[x] %>%
strsplit('( |, )+') %>%
unlist %>% as.numeric)
}) %>%
bind_rows()
# plot ----
clean_dat %>%
arrange(name) %>%
group_by(choices) %>%
mutate(y=row_number()) %>%
ungroup() %>%
ggplot(aes(x=factor(choices), y=y, color=name)) +
geom_point(size=10) +
theme_light() +
labs(title='bcc #food potato prefs', x='spud style', y='vote tally')
@arvi1000
Copy link
Author

arvi1000 commented May 1, 2020

image

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