Rmarkdown and Shiny input

后端 未结 1 1929
陌清茗
陌清茗 2020-12-21 17:46

I\'m attempting my first Markdown doc and everything has been going smoothly until I get the error

 \"Error in eval(expr, envir, enclos) : obje         


        
相关标签:
1条回答
  • 2020-12-21 18:23

    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()
    })
    
    0 讨论(0)
提交回复
热议问题