首页 > 解决方案 > 基于 SelectiveInput R Shiny 渲染箱线图

问题描述

我正在尝试通过选择性输入在 R 中渲染一些箱线图。我有我的选择,但是当我运行应用程序时,它只是说找不到对象并且不会渲染。这是我的 ui 代码,plotoutput 是“boxplot”:

selectInput(inputId = "Input3", "Boxplot:", 
            choices = c(label = NULL,
                        'Gunning Fog Index'= 'gfi',
                        'Percentage of hard words'= 'pohw',
                        'Flesch Readability Ease' = 'flesch',
                        'Automated Readability Index' = 'ari',
                        'Percentage of first person pronouns' = 'pofpp',
                        'Percentage of third person pronouns' = 'potpp')),

这是我的服务器代码:

output$boxplot <- renderPlot({
par(mfrow=c(1, 2))
# generate bins based on input$bins from ui.R
boxplot(get(input$Input3), Flesch_fake, ylim = c(-20, 60), col = "red", main="Flesch Reading Ease - Fake")
})

如果我尝试在 renderPlot 函数中的 Input3 之后使用 $flesch,则表示该运算符对原子向量无效。我怎样才能解决这个问题,只需通过 SelectiveInput 渲染一个箱线图?该应用程序本身可以工作,只是不会呈现箱线图。

标签: rshiny

解决方案


推荐阅读