目前,我正在开发一个Shiny应用。在sidebarPanel
的UI
中,根据数据帧的数字列创建多个selectInput
选项。对于数据框中的每个非数字列(基于用户已选择的excel文件),将创建selectInput
选项:
df<-iris
lapply(names(df %>% select_if(~is.numeric(.x)) %>% head()), function(i) { selectInput(paste0(i), paste0(i),
choices = df[i],
multiple = TRUE,
selected = "")})
在脚本的Server
中,需要获取一个基于用户输入的数据帧。但是,我当前的方法不起作用:
Sepal.Length<-c(5.1,4.6)
Sepal.Width<-c(3.0)
Petal.Width<-c(0.2,0.3)
Petal.Length<-c(1.4,1.3)
input<-data.frame(Sepal.Length,Sepal.Width,Petal.Length,Petal.Width)
data<-df
lapply(names(df %>% select_if(~is.numeric(.x)) %>% head()), function(i) {
data <- subset(data,
i %in% input[[i]])
})
有人可以帮助我获取基于用户输入的数据帧(数据)吗?