Question: library ( shiny ) library ( shiny ) library ( tidyverse ) library ( gtrendsR ) library ( ggplot 2 ) library ( lubridate )

library(shiny)
library(shiny)
library(tidyverse)
library(gtrendsR)
library(ggplot2)
library(lubridate)
Data<-gtrends(keyword=c('APPLE','META'))
Apple <-filter(Data$interest_over_time, keyword =="APPLE")
Meta <-filter(Data$interest_over_time, keyword == "META")
Apple$date = as.Date(Apple$date)
Meta$date = as.Date(Meta$date)
ui <- fluidPage(
titlePanel('Apple Hits Over Time'),
sidebarLayout(
sidebarPanel(
dateRangeInput("daterange1", "Date range:",
start = Sys.Date()-60,
end = Sys.Date()),
plotOutput("Apple_plot")
)
dateRangeInput("daterange2", "Date range:",
start = Sys.Date()-60,
end = Sys.Date())
plotOutput("Meta_plot")
server <- function(input, output){
output$Apple_plot <- renderPlot({
output$Meta_plot <- renderPlot
data_m<-filter(Apple,date>=as.Date(input$daterange1[1]) &
date<=as.Date(input$daterange1[2]))
ggplot(data_m,
aes(x=date,y=hits))+
geom_point()+
xlab("Date")+
ylab("Hits")
})
}
shinyApp(ui, server)
Download data for names of any two companies of your interest from Google Trends. You can use the following example code: Data<-gtrends(keyword=c('APPLE','META'))
Create a Shiny app with date-range input to select a start date and an end date.
The Shiny app should show a point plot for both companies over time. The points should have different colors based on the company (use color parameter of ggplot)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!