library(tidyverse)
<- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-04-19/big_dave.csv')
big_dave <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-04-19/times.csv') times
%>%glimpse
big_dave%>%arrange(-rowid)%>%head big_dave
<- big_dave%>% # DataExplorer::profile_missing()
big_dave1 select(answer,puzzle_date,puzzle_name) %>%
filter(!is.na(answer)) %>%
mutate(puzzle_bigdave=gsub("[[:punct:][:blank:]]\\d*","",puzzle_name))
%>%count(answer) big_dave1
%>%glimpse
times%>%head times
<- times%>%
times1 select(answer,puzzle_date,puzzle_name) %>% #DataExplorer::profile_missing()
filter(!is.na(answer))%>%
mutate(puzzle_times=gsub("[[:punct:][:blank:]]\\d*","",puzzle_name))
%>%count(answer) times1
<- big_dave1 %>%
df inner_join(times1,by=c("answer","puzzle_date")) %>%
arrange(puzzle_date) %>% #
mutate(answer=as.factor(answer)) %>% #DataExplorer::profile_missing()
select(-puzzle_name.x,-puzzle_name.y) %>%
mutate(year=lubridate::year(puzzle_date),.after=answer,
year=as.integer(year))
df
%>%
dfggplot(aes(x=year,y=puzzle_bigdave))+
geom_col()
library(gganimate)
<- colorRampPalette(RColorBrewer::brewer.pal(12, "Paired"))(161)
colorslibrary(extrafont)
loadfonts()
library(showtext)
#
font_add_google("Gentium Book Basic","gbb")
font_add_google("Nanum Gothic","ng")
showtext_auto()
<- df %>%
p pivot_longer(cols=c("puzzle_bigdave","puzzle_times"),
names_to="names",values_to="values")%>%
#count(year)
ggplot(aes(puzzle_date, fct_reorder(values,puzzle_date), color = values)) +
geom_jitter(show.legend = F,shape=".",color="white")+
geom_text(aes(label=answer),
size=9,
check_overlap = T,family="gbb")+
scale_color_manual(values=colors)+
labs(title = "\nSame Answers! Year: {closest_state}\nBigDave & Times puzzles\n",
subtitle="\nwords are randomized",
caption="#30DayChartChallenge 2022 #Day22\n DataSource: #TidyTuesday week16 - Crossword \n DataViz: Federica Gazzelloni\n\n")+
theme_void() +
theme(text = element_text(family = "ng", face="bold",color="#F0F8FF"),
plot.title = element_text(size=28),
plot.subtitle = element_text(size=18),
plot.caption = element_text(size=14,vjust=2,hjust=0.5),
plot.background = element_rect(fill="grey10",color="grey20"),
panel.background = element_rect(fill="grey10",color="grey20"),
legend.position = "none")+
coord_polar(theta = "x") +
transition_states(year,
transition_length = 2,
state_length = 1,
wrap = F) +
shadow_wake(wake_length = 0.5,wrap=F)
anim_save(animate(p,res=100,
renderer = gifski_renderer("animation3.gif"),
height = 710, width = 610))
%>%
df pivot_longer(cols=c("puzzle_bigdave","puzzle_times"),
names_to="names",values_to="values")%>%
ggplot(aes(year, fct_reorder(values,year), fill = values)) +
geom_col() +
scale_fill_viridis_d() +
theme_minimal() +
theme(legend.position = "none",
panel.grid = element_blank(),
panel.grid.major.y = element_line(color = "white"),
panel.ontop = TRUE
+
)coord_polar()+
facet_wrap(vars(names))+
transition_states(year, wrap = FALSE) +
shadow_mark()+
enter_grow() +
enter_fade()
%>%
dfgroup_by(puzzle_times)%>%
count(year,sort=T)
<- df%>%
bd_id arrange(puzzle_date)%>%
count(puzzle_bigdave)%>%
mutate(bd_id=row_number())#%>%
#select(-n)
<- df%>%
tm_id arrange(puzzle_date)%>%
count(puzzle_times)%>%
mutate(tm_id=row_number())#%>%
#select(-n)
<- df %>%
df1 left_join(bd_id,by=c("puzzle_bigdave"))%>%
left_join(tm_id,by="puzzle_times")
df1
library(tidyverse)
library(viridis)
library(patchwork)
library(hrbrthemes)
library(igraph)
library(ggraph)
library(colormap)
<-df1%>%
links mutate(label=paste0(puzzle_bigdave,"-",puzzle_times))%>%
rename(source=bd_id,target=tm_id)
library(ggbump)
ggplot(links,aes(x=source-2,xend=source+5 ,y=target,yend=target+5,
group=label)) +
::geom_sigmoid(aes(color=puzzle_bigdave),show.legend = F)+
ggbumpgeom_text(aes(x=source-2,label=puzzle_bigdave),size=3,
vjust="bottom",hjust="right",check_overlap = T,show.legend = F)+
geom_text(aes(x=source+5,y=target+5,label=puzzle_times),size=3,
vjust="bottom",hjust="left",check_overlap = T,show.legend = F)+
geom_text(aes(label=answer,color=answer),size=3,
vjust="bottom",hjust="left",check_overlap = T,show.legend = F)
coord_flip()
lot(df, aes(x=year, y= fct_reorder(puzzle_bigdave,year)))+
geom_col()+
#scale_x_continuous(breaks=seq(2014,2021,1))
labs(title="Big Dave")
ggplot(df, aes(x=puzzle_date, y= puzzle_times))+
geom_col()+
labs(title="Times")