Reputation: 3515
I'm attempting my first Markdown doc and everything has been going smoothly until I get the error
"Error in eval(expr, envir, enclos) : object 'input' not found"
with this chunk
{r, echo=FALSE}
inputPanel(
radioButtons("category",label= "Select Category",choices=c("diffPts","diffGF","diffGA","diffGD","diffpos"),inline = TRUE)
)
renderPlot({
ggplot(clubSeason, aes(x=team, y=input$category)) + geom_boxplot()
})
if I hardcode e.g y="diffPts"
the chart displays. Putting a print()
around the ggplot does not help
TIA
Upvotes: 2
Views: 1722
Reputation: 30455
Following runs fine for me. The value of ìnput$category` is printied as expected
---
title: "Untitled"
runtime: shiny
output: html_document
---
```{r, echo=FALSE}
library(ggplot2)
inputPanel(
radioButtons("category",label= "Select Category",choices=c("diffPts","diffGF","diffGA","diffGD","diffpos"),inline = TRUE)
)
renderPlot({
print(input$category)
ggplot(faithful, aes(x=eruptions, y=waiting)) + geom_boxplot()
})
```
UPDATE:
The issue appears to be with the aes
function being passed a string. You can use aes_string
instead:
renderPlot({
ggplot(clubSeason, aes_string(x='team', y=input$category)) + geom_boxplot()
})
Upvotes: 2