-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
107 lines (107 loc) · 2.71 KB
/
.Rhistory
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
shiny::runApp()
install.packages("shiny")
install.packages("shiny")
shiny::runApp()
?plotlyoutput
?plotlyOutput
??plotlyOutput
library(shiny)
library(twitteR)
# Team:
#
# Ben Basinski
#
#
#
#
shinyServer(function(input, output) {
library(shiny)
library(twitteR)
source("./scripts/twitterauth.r")
source("./scripts/wordcloud.r")
source("./scripts/location.r")
source("./scripts/plot.r")
#Authentication
Twitter.Auth()
#Calls the function to get tweet content from twitter depending on the type of search
getTweets <- function() {
searchterm <- tolower(input$searchId)
if (input$searchInput == "Search") {
tweets <- getTweetsFromSearch(searchterm, input$nResults)
} else if (input$searchInput == "Trending") {
tweets <- getTweetsFromSearch(searchterm, input$nResults)
} else {
tweets <- getTweetsFromUser(searchterm, input$nResults)
}
return (tweets)
}
#calls the getTweets function only when the search button is pressed
tweets <- eventReactive(
input$Search,{getTweets()}
)
#renders the text at the top of the page for the search that is being done
output$search <- renderText({
if (input$searchInput == 'Search') {
paste("Search: ", input$searchId)
} else if (input$searchInput == 'Trending') {
paste("Trend: ", input$searchId)
} else {
paste("User: ", input$searchId)
}
})
#outputs a regular word cloud to the page
output$wordcloud <- renderPlot({
getWordCloud(tweets())
})
#outputs a sentiment word could to the page (only contains words with sentiments)
output$sentimentcloud <- renderPlot({
getSentimentCloud(tweets())
})
#outputs a bar graph of the types of emotions that are expressed in the tweets
output$feeling <- renderPlotly({
getFeeling(tweets())
})
#the function that figures out the type of search that the user wants to do
searchtype <- reactive(
if (input$searchInput == "Trending") {
selectInput(inputId = 'searchId', 'Select a trend:', getTrendsWC(23424977)) #trends nationwide
} else if (input$searchInput == "Search") {
textInput(inputId = "searchId", "Enter Search:", "uw")
} else {
textInput(inputId = "searchId", "Enter Username: (exclude @)", "katyperry")
}
)
#outputs the type of search the user wants to do from the function searchType()
output$searchtype <- renderUI({
searchtype()
})
# renders the map for the second tab
output$map <- renderPlotly({
df <- read.csv("./Data/city_data.csv")
g <- Top.Map(df)
g
})
# renders the plot for the third tab
output$accounts <- renderPlotly({
y.axis <- input$y_input
accountChart(y.axis)
})
})
library(tidytext)
library(reshape2)
library(wordcloud)
library(dplyr)
library(plotly)
install.packages("ggplot2")
install.packages("ggplot2")
library(tidytext)
library(reshape2)
library(wordcloud)
library(dplyr)
library(plotly)
shiny::runApp()
shiny::runApp()
library plotly
library(plotly)
runApp()
shiny::runApp()