-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.R
173 lines (156 loc) · 5.73 KB
/
ui.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
library(shiny)
library(shinythemes)
library(ggplot2)
library(dplyr)
library(lubridate)
library(scales)
library(stringr)
library(tm)
library(RColorBrewer)
library(wordcloud)
library(tidytext)
library(zoo)
library(shinycssloaders)
library(rvest)
library(parsedate)
library(purrr)
library(plotly)
options(shiny.maxRequestSize=100*1024^2)
options(expressions = 10000)
options(spinner.type = 1)
#ui------------------
ui <- fluidPage(
title = "SearchAna",
theme = shinytheme("journal"),
wellPanel (
h1("SearchAna"),
p("This is a R based app which analyzes your Google Searches over the years."),
p(tags$b("The app does not store any of your information.")),
p("To run the app you need to download your google search history. For this you'll have to:"),
tags$ol(
tags$li("Visit website---", tags$a(href="https://takeout.google.com/settings/takeout?pli=1","Download data from Google Account", target= "_blank")),
tags$li("Select none (unless you want to download other data)"),
tags$li("Go to My Activity and toggle it on"),
tags$li("Select specific activity data"),
tags$li("Select Search"),
tags$li("Next and download the Archive"),
tags$li("Extract the Archive"),
tags$li("Remember the location of the extracted archive"),
tags$li("Now in the app, 'Browse' to your to the extracted archive"),
tags$li("Goto Takeout >> My Activity >> Search >> Upload file named (My Activity.html) (NOT index.html)")
),
p("Enjoy the app! :)"),
p("Made By Prateek Arora"),
p("Code available at ", tags$a(href="https://github.com/pratarora/Personal-google-search-analysis", "Github.", target= "_blank"))
),
sidebarLayout(
#sidebar panel UI-------------
sidebarPanel(
#input JSON files
fileInput(
inputId = "file_input",
"Upload .html Google Search takeaway files",
multiple = TRUE,
accept = ".html"
),
#download csv file
downloadButton(outputId = "downloadData", label = "Download the csv"),
#input date range for analysis based on input files
uiOutput("date_range"),
tags$hr(),
tabsetPanel(
type = "pills",
id = "sidetabselection",
#search count analysis ui----------------
tabPanel(
"Search Count Analysis",
value = 1,
radioButtons(
inputId = "analysis_type",
label = "How would you like your analysis to be performed?",
c(
"Yearly" = "yearly",
"Quarterly" = "quarterly",
"Monthly" = "monthly",
"Weekly" = "weekly",
"Daily" = "daily",
"Hourly" = "hourly",
"According to days of the week" = "weekdays",
"Hourly searches on different days of the week"="hourly_weekday",
"According to months in a year" = "month_pooled",
"According to dates of the month" = "dates_pooled"
),
selected = "monthly"
)
),
#word analysis ui-----------------
tabPanel(
"Word Analysis",
value = 2,
textInput(
inputId = "filterwordsinput",
label = "Words to remove from the analysis (Seprate words by a space)",
value = NULL
),
radioButtons(
inputId = "word_analysis_type",
label = "How would you like your analysis to be performed?",
c("Word Cloud" = "wordcloud",
"Word Frequency chart" = "word_freq"),
selected = "wordcloud"
),
checkboxInput(inputId = "word_assoc", label = "See word associations" , FALSE),
conditionalPanel(
"input.word_assoc==true",
selectInput(
inputId = "wordnum",
label = "Which word's association would you like to know",
multiple = FALSE,
c(
"Select Word",
"First Word" = "one",
"Second Word" = "two",
"Third Word" = "three",
"Fourth Word" = "four",
"Fifth Word" = "five"
)
)
),
)
)
#select what type of analysis is to be done
#switch command?
),
#main panel UI------------
mainPanel(
conditionalPanel(
condition = "input.sidetabselection==1",
fluidRow(
plotlyOutput("graph", width = "100%", height=500) %>% withSpinner()
),
fluidRow(
downloadButton(outputId = "download_searchcount",
label = "Download the plot")
)),
conditionalPanel(
condition = "input.sidetabselection==2",
conditionalPanel(condition = "input.word_analysis_type==wordcloud",
fluidRow(
plotOutput(
"wordcloudout", width = "100%", height = 500
)%>% withSpinner()
)#,
# downloadButton(outputId = "wordcloudplot",
# label = "Download the plot")
),
# uiOutput("wordassocout")
# fluidRow(conditionalPanel(condition = "input.word_topic=true",
# verbatimTextOutput("wordtopicout"))%>% withSpinner()),
conditionalPanel(condition = "input.word_assoc=true",
plotlyOutput("wordassocout", width = "100%", height=500) %>% withSpinner()
)
# conditionalPanel(condition ="input.word_assoc=false",
# removeUI("wordassocout"))
)
)
))