-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTidytuesday20220927.R
50 lines (40 loc) · 1.51 KB
/
Tidytuesday20220927.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
library(tidyverse)
library(readr)
# Get the Data
# read in the data manually
artists <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-09-27/artists.csv')
#eda
artists %>%
group_by(type,state) %>%
summarise( total= sum(artists_share)) %>%
ggplot(aes(x=total,color=state,fill=state)) + geom_histogram()+
scale_x_log10(labels = scales::label_percent()) +
facet_wrap(.~type) +
ggthemes::theme_economist( )
artists %>%
group_by(type,state) %>%
summarise( total= sum(artists_share)) %>%
pivot_wider(id_cols= state ,names_from=type, values_from=total )
ggplot(aes(x=total,color=state,fill=state)) + geom_histogram()+
scale_x_log10(labels = scales::label_percent()) +
facet_wrap(.~type) +
ggthemes::theme_economist( )
artists %>%
group_by(type,state) %>%
summarise( total= sum(artists_share,na.rm=T)) %>%
pivot_wider(id_cols= state ,names_from=type, values_from=total ) %>%
ungroup %>%
#names
ggplot(aes(x=Musicians, y=Architects,col=state,label=state)) + geom_label()+
ggthemes::theme_economist( )+
guides(color = FALSE)
#cluster with hierarchical cluster highlighting 4 groups with rects
artists %>%
group_by(type,state) %>%
summarise( total= sum(artists_share,na.rm=T)) %>%
pivot_wider(id_cols= state ,names_from=type, values_from=total ) %>%
ungroup %>%
#names
select(!state) %>%
cor(use = 'everything') %>%
corrplot::corrplot( method = 'number', , order = 'hclust', addrect = 4)