-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
119 lines (104 loc) · 3.43 KB
/
app.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
library(shiny)
library(networkD3)
setwd(getwd())
source("plot-input.R")
default_terms <- c("kormány","Orbán","Soros")
min_date <- "2015-05-20"
max_date <- "2018-03-09"
# Read prepared data
word_corrs <- read.delim("data/word_corrs.tsv", sep = "\t", encoding = "UTF-8", stringsAsFactors = F)
unique_terms <- unique(c(word_corrs$item1, word_corrs$item2))
# Server Logic
server <- function(input, output) {
graph_input = reactive({
valid_terms <- prepare_input_terms(input$terms_input, unique_terms)
return(
generate_graph_plot_input(
word_corrs,
valid_terms,
input$min_corr
)
)
});
output$force <- renderForceNetwork({
simpleNetwork(
graph_input(),
zoom = T
)
})
}
# UI
ui <- shinyUI(
fluidPage(
title = "Analysis of Zsolt Bayer's blog",
tags$head(
includeHTML("google-analytics.html"),
tags$style(
type="text/css",
"img {max-height: 150px; display:inline-block;}"
)
),
fluidRow(
# column(
# width = 2,
# align="center",
# div(
# class="thumbnail",
# img(
# src="http://www.sztarklikk.hu/images/articleMain/33421.jpg",
# align="center",
# class="img-responsive"
# )
# )
# ),
column(
width = 10,
offset = 1,
h1("Word Association Network of Blog Post from Zsolt Bayer"),
p(
"This website visualizes the word association network obtained from blog posts by",
a(href="https://badog.blogstar.hu/", "Zsolt Bayer.", target="_blank"),
"Mr. Bayer is a publicist from Hungary known in the political life as an ardent supporter of Viktor Orbán, prime minister of Hungary (1998-2002, 2010-), and the party Fidesz."
),
p(
"After scraping all blog posts from the time period from",
min_date,
"to",
max_date,
"(scraper script",
a(href="https://github.com/kubikb/bayer_blog_parser", "HERE", target="_blank"),
"), data was cleaned, lemmatized using the awesome",
a(href="http://www.inf.u-szeged.hu/rgai/magyarlanc", "Magyarlánc tool", target="_blank"),
"and analyzed with the help of",
a(href="https://github.com/juliasilge/tidytext", "tidytext for R.", target="_blank")
),
p(
"It was created by",
a(href="https://www.linkedin.com/in/balintkubik/", "Bálint Kubik", target="_blank"),
"to play with network visualization in",
a(href="https://shiny.rstudio.com/", "Shiny for R.", target="_blank"),
"Github repository with the source can be found",
a(href="https://github.com/kubikb/bayer-shiny-analysis", "HERE.", target="_blank")
)
)
),
fluidRow(
column(6,
align="center",
textInput("terms_input", h3("Terms to analyze (comma-separated)"),
placeholder = paste("For example:", paste(default_terms, collapse = ", ")),
value = paste(default_terms, collapse = ", "))
),
column(6,
align="center",
sliderInput("min_corr", h3("Minimum correlation between terms"),
min = 0.1, max = 1.0, value = 0.15)
)
),
fluidRow(
forceNetworkOutput("force")
)
)
)
# Run the app ----
shinyApp(ui = ui, server = server)