【问题标题】:How to parse radiobutton value in shiny R如何在闪亮的R中解析单选按钮值
【发布时间】:2020-11-10 02:59:38
【问题描述】:

我有一个单选按钮,每个选项都有条件面板,如下所示:

radioButtons("map_subset",label="enter choices or upload your own subset?",
                    choices=c("enter","upload"),selected="enter"),
       
       conditionalPanel("input.map_subset=='enter'",
                        selectizeInput(inputId = "map_enterinput",
                                       label = "Select input",
                                       choices = NULL,
                                       multiple = TRUE,
                                       options = list(placeholder = 'enter names'))
                        ),
       
       conditionalPanel("input.map_subset=='upload'",
                        fileInput('map_file', 'Choose File Containing IDs\n(one row per ID)',
                                  accept=c('text/csv', 
                                           'text/comma-separated-values,text/plain', 
                                           '.csv'))

简而言之,selectizeInputfileInput 输入选项根据所选单选按钮激活。

在闪亮的应用程序中,有一个函数可以根据radioButton 选择的输入对数据集进行子集化。

 map_render(
    data_analy=data_analyzed,
    usesubset = input$map_subset == "enter")

这里我需要usesubset 参数来获取radioButton 所做选择的值

即如果选择了enter,那么

map_render(
data_analy=data_analyzed,
usesubset = input$map_subset == "enter")

或者如果选择upload,那么

map_render(
    data_analy=data_analyzed,
    usesubset = input$map_subset == "upload")
  

有人可以提供帮助来实现这一点。

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    input$map_subset 将具有选定单选按钮的值。

    那么这应该可以工作:

    map_render(
        data_analy=data_analyzed,
        usesubset = input$map_subset)
    

    【讨论】:

    • 给出错误:Error: operations are possible only for numeric, logical or complex types
    • 也许这是您正在寻找的后续输入的值:map_render( data_analy=data_analyzed, if (input$map_subset == "enter") usesubset = input$map_enterinput else if (input$map_subset == "upload") usesubset = input$map_file )
    • 论点usesubset 在与if((usesubset)&(!is.null(subsetids))) {thesege = subsetids} 不同的代码块中进行评估。这是罪魁祸首吗?
    • 对于你提到的错误我发现:“具体的错误是由你使用&分隔代码行引起的;这不起作用,因为这是R中的逻辑运算符。你可以使用 ; 代替或换行符来分隔行。” 这可能是您的情况吗?它是否还为您提供了发生错误的代码行?
    • 控制台显示115: map_subdat [fun.R#57] 114: heatmap_data [fun.R#169] 113: <reactive:HeatdatReactive_rna> [server.R#115] 97: HeatdatReactive_rna 96: renderText [server.R#337]
    猜你喜欢
    • 1970-01-01
    • 2021-05-01
    • 2020-06-20
    • 1970-01-01
    • 1970-01-01
    • 2021-05-16
    • 2019-08-02
    • 2019-02-10
    • 2021-12-14
    相关资源
    最近更新 更多