I have this dataset here and I would like to create a simple Slider Input where the respective average Temperature of the country will change by changing the year. So far I have written this. I want to project the average Temperature of Canada throughout the years from 1743 till 2013. How should I proceed in making this happen?
ui.R
fluidPage(
verticalLayout(
titlePanel("Russian Average Temperature"),
plotOutput("plot1"),
wellPanel(
sliderInput("Year", "Timeline", 1743, 2013,
value = 0, step = 1)
)
)
)
server.R
library(shiny)
library(dplyr)
library(tidyr)
library(ggplot2)
data <- read.csv("..\\GlobalLandTemperatures\\GlobalLandTemperaturesByState.csv",
fileEncoding = "UTF-8")
function(input, output) {
data %>%
filter(Country=="Canada") %>%
separate(col = dt, into = c("Year", "Month", "Day"), convert = TRUE) ->cCanada
cCanada<-na.omit(cCanada)
cCanada %>%
filter(Year>1743) %>%
group_by(Year) %>%
summarise(Temp = mean(AverageTemperature)) ->cCanAvgTemp
output$plot1 <- renderPlot({
plot(x = Year, y = AverageTemperature)
})
}
