【发布时间】:2017-05-25 11:54:03
【问题描述】:
我有一个数据集,其列名格式为:textyear,例如:John2011、Jack2012。
是否可以使用以下方法从数据集中对特定列进行子集化:
selectInput("name",...
sliderInput("year",...
如果在 selectInput name 用户输入姓名,如:John 等,在 selectInput year 用户输入年份,如:2011强>
【问题讨论】:
-
是什么阻碍了你?
paste0(input$name, input$year)将在服务器函数中生成列名。 -
AlexR 谢谢。是否可以使用这种策略来获得类似:new_df % select(col1, grep(paste0(input$name, input$year)))??
-
select_(.dots = c("col1", paste0(input$name, input$year)))。为什么还要费心使用grep? -
这看起来很棒。如果我想在两个输入(如 JohnMr2011、JackMr2012)之间合并一些静态文本 Mr 怎么办?该文本不是来自用户的输入,只是每个列名中的一部分?我试过 select_(.dots = c("col1", paste0(input$name, ""Mr", input$year))) 没有成功
-
我认为,如果您查看文档,您会自己弄清楚。