I have my data frame named df...
pain_severity = c(1, 5, 10, 8, 6, 4)
urinary_severity = c(3, 8, 9, 7, 6, 10)
df = data.frame(pain_severity, urinary_severity)
I let the user choose whether they want pain or urinary severity in select input...
UI:
tabPanel("1-Variable Visualization",
sidebarLayout(
sidebarPanel(
h1("Menu Selection"),
selectInput(inputId = "variable_choice",
label = "Variable",
choices = df,
selected = "pain_severity")
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Boxplot", plotOutput("boxplot")),
)))))
SERVER:
server <- function(input, output, session) {
output$boxplot <- renderPlot({
boxplot(input$variable_choice,
data = df,
main = "", xlab="", ylab = "", horizontal = TRUE)
points(mean(input$variable_choice, na.rm = TRUE),
data = df,
1,
col = "red")
})
}
I keep getting an error that reads... ERROR: non-numeric argument to binary operator
Why does this happen? When I run the code in base R using just pain or urinary severity as my variable it works perfectly. When I ask it to adapt based on user input from variable_choice, it gives me that error message. Do I have to use ggplot when trying to run user inputs?