我正在开发一个Shiny应用程序,允许用户上传自己的数据,并通过提供下图所描述的数据过滤小部件来关注整个数据或子集
选择输入" 变量1 "将显示用户上传的数据的所有列名称,并且选择性输入" 值 "将显示在" 变量1 "中选择的相应列的所有唯一值.理想情况下,用户可以通过某种触发器添加尽可能多的此类行(" 变量X "+" 值 "),一种可能是单击"添加更多"操作按钮.
网上通缉后,我发现给出一个可行的解决方案尼克Carchedi粘贴下面
ui.R
library(shiny)
shinyUI(pageWithSidebar(
# Application title
headerPanel("Dynamically append arbitrary number of inputs"),
# Sidebar with a slider input for number of bins
sidebarPanel(
uiOutput("allInputs"),
actionButton("appendInput", "Append Input")
),
# Show a plot of the generated distribution
mainPanel(
p("The crux of the problem is to dynamically add an arbitrary number of inputs
without resetting the values of existing inputs each time a new input …Run Code Online (Sandbox Code Playgroud) 这可能是一个愚蠢的问题,但我已经困扰了很长一段时间.我看到人们在定义函数时使用单引号括起函数名.我一直在想这样做的好处.以下是一个天真的例子
'row.mean' <- function(mat){
return(apply(mat, 1, mean))
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!