I am currently filtering some data to be plotted and have decided to use the apply.weekly function to show the weekly mean of a variable (weight) for a group of people over a period of time.
I think my code is very close to correct. When I run the code, I get the following error "Error in FUN: object 'Date' not found"
I have provided a small bit of the relevant code. Any help would be great!!
'''
ui <- dashboardPage(
checkboxGroupInput("Teaminput", "Select Team", c("Team 1", "Team 2"), selected ="Team 1"),
selectInput( "Category", "Select Category", c("Overview", "Position", "Age", "Player"))
plotOutput("Plot1"))
server <- function(session, input, output) {
output$plot1 <- renderPlot({
filtered_data1 <- filter(df, Date >= format(input$daterange[1]) & Date <= format(input$daterange[2])) %>%
filter(Team %in% input$Teaminput)
if (input$Category == "Overview") {
dfavg1 <- xts(df$Weight, as.Date(df$Date))
variable_df1 <- apply.weekly(dfavg1, mean)
}
ggplot(variable_df1, aes(x= Date, y = Weight))
})
}
Here is the packages loaded:
library (dplyr)
library(shiny)
library (shinydashboard)
library(ggplot2)
library(readr)
library(plotly)
library(xts)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…