Using the mtcars dataset in R, I am tying to use the input variable (cyl, am etc...) to calculate the mean mpg by that variable.
My code in the ui.R is like:
verbatimTextOutput("Avg_Mileage")
My code in the shinServer function in server.R is like:
carsdata <- mtcars
output$Avg_Mileage <- renderPrint({aggregate(mpg~input$variable, carsdata,mean)})
I have tried to change the code in server.R in various ways. But I keep getting the message about conflicting variable lengths: "variable lengths differ (found for 'input$variable')"
I would appreciate any help in trying to see how can this mean mpg by input variable be implemented in Shiny
No comments:
Post a Comment