Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Networking is a two-way street. Discuss this statement.

Answered: 1 week ago