-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathftips_meta.Rmd
95 lines (67 loc) · 1.83 KB
/
ftips_meta.Rmd
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
title: "Analysis of Fingertips metadata"
author: "Julian Flowers"
date: "25/06/2017"
output:
ioslides_presentation:
incremental: yes
keep_md: yes
smaller: yes
widescreen: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, cache = TRUE, message = FALSE, warning = FALSE)
library(fingertipsR)
library(tidyverse)
library(stringr)
library(tidytext)
library(wordcloud)
library(topicmodels)
library(text2vec)
library(LDAvis)
```
## Metadata
```{r, cache=TRUE}
prof_meta <- indicator_metadata(ProfileID = c(19, 40))
glimpse(prof_meta)
```
## Meta
```{r, cache=TRUE}
prof_meta %>% slice(7) %>%
t() %>%
data.frame() %>%
knitr::kable()
prof_id <- indicators(ProfileID = c(19, 40))
prof_meta <- prof_meta %>%
left_join(prof_id, by = c("Indicator.ID" = "IndicatorID"))
text <- prof_meta %>%
select(Indicator.ID, DomainName, Indicator.full.name, Definition, Rationale)
```
## Comparison cloud
```{r, fig.height=5, fig.width=10}
text <- text %>%
mutate_if(is.factor, as.character) %>%
unite(text, c(Indicator.full.name, Definition, Rationale))
text$text <- tm::removeNumbers(text$text)
text$text <- tm::removePunctuation(text$text)
text$text <- tolower(text$text)
tidymeta <- text %>%
unnest_tokens(word, text) %>%
anti_join(stop_words) %>%
arrange(DomainName) %>%
count(DomainName, word, sort = TRUE) %>%
reshape2::acast(word ~ DomainName,
value.var = "n", fill = 0) %>%
comparison.cloud(max.words = 500, title.size = .8, random.order = FALSE, rot.per = 0.4)
```
## Commonality cloud
```{r , echo = TRUE}
text %>%
unnest_tokens(word, text) %>%
anti_join(stop_words) %>%
arrange(DomainName) %>%
count(DomainName, word, sort = TRUE) %>%
reshape2::acast(word ~ DomainName,
value.var = "n", fill = 0) %>%
commonality.cloud(max.words = 100)
```