-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmetadata.R
63 lines (44 loc) · 1.63 KB
/
metadata.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
51
52
53
54
55
56
57
58
59
60
61
62
63
library(fingertipsR)
library(dplyr)
library(stringr)
library(tidytext)
library(corrr)
library(gganimate)
library(ggplot2)
install.packages('installr')
install.packages('devtools')
install.ImageMagick()
devtools::install_github("yihui/animation")
devtools::install_github("dgrtwo/widyr")
library(widyr)
ind_risk <- indicators()
head(ind_risk)
profile_risk <- profiles()
profile_risk %>%
select(ProfileID, ProfileName) %>%
distinct
ind_meta <- indicator_metadata(ProfileID = c(8, 32, 94, 98, 121, 129, 37))
head(ind_meta)
str(ind_meta)
surveys <- ind_meta %>%
filter(str_detect(Data.source,"[Ss]urvey" )) %>%
select(Data.source)
profiles <- read.csv("~/Documents/R_projects/profiles/profile.csv")
glimpse(profiles)
corr <- correlate(profiles[, -c(1:2)])
network_plot(corr, colors = c("red", "green"), min_cor = 0.7, legend = TRUE)
library(purrr)
corr %>% shave(upper = FALSE) %>% rplot() + theme(axis.text.x = element_text(angle = 45, hjust = 1))
### Animate.....
phof <- fingertips_data(ProfileID = 19)
unique(phof$IndicatorName)
p <- phof %>%
filter(IndicatorName == "0.1ii - Life expectancy at 65" |IndicatorName == "0.1ii - Life expectancy at birth" , AreaType == "County & UA", CategoryType == "") %>%
select(IndicatorName, ParentName, AreaName, Timeperiod, Sex, Value) %>%
spread(IndicatorName, Value)
p1 <- p %>%
ggplot(aes( Sex,`0.1ii - Life expectancy at 65`, fill = ParentName,shape = Sex, frame = Timeperiod)) +
geom_boxplot() +
facet_wrap(~ParentName) +
theme(legend.position = "bottom", axis.text.x = element_text(angle = 45, hjust = 1))
gganimate(p1, filename = "gapminder-gganimate.html")