[英]How to make ui.R and server.R to import function and data from other file and plot in ShinyApp
[英]ui.R returning check-box data to server.R, but how to convert “closure” to vector in the server.R file?
我的ui.R文件具有以下内容,允许用户选择复选框。 当我尝试通过以下方法在server.R文件中理解它时:
a <- renderText({ print(input$checkGroup) })
df <- df %>% filter(match(mfr, a)) %>% select(df)
我收到以下错误:
filter_impl(.data,点)中的错误:“匹配”需要向量参数
我尝试在StackOverflow上寻找答案,有人建议使用cat运算符,但是当我这样做时,我得到了
参数1(类型为“ closure”)不能由“ cat”处理
fluidPage(
checkboxGroupInput('checkGroup', label = h3("Checkbox group"),
choiceNames = list(...),
choiceValues = list('N', 'A', 'G', 'K', 'P', 'Q', 'R'),
selected = 'N'),
hr(),
fluidRow(column(3, verbatimTextOutput("value")))
)),
编辑-嘿,谢谢您的评论! 在我的情节中,我有以下代码:
<code> x = df[[input$nutri]], </code>
如何修改它以使用df()? 如果使用df(),则会出现以下错误:
过滤条件不等于逻辑向量
我尝试将其更改为
<code> r_df <- reactive({df %>% filter(mfr %in% r_a()) %>% select(df)}) </code>
但我明白了
所有select()输入必须解析为整数列位置。 以下内容不:* df
作为提示,我正在检查向量r_a是否具有等于df中值的元素。
使用反应物:
r_a <- reactive(input$checkGroup)
r_df <- reactive({df %>% filter(match(mfr, r_a())) %>% select(df)})
然后在renderPlot
使用r_df()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.