r - 无法创建 1 列数据框的 selectInput
问题描述
我正在尝试使用 selectInput 选择数据样本。我想在我的数据框中构建一个特定 sample_ids 的下拉菜单,并使用它从更大的数据框中将该样本 id 子集化以供以后绘制。但是,我无法正确构建此下拉菜单。
在您的工作目录中创建一个名为“SampleDataFolder”的文件夹,并将 .csv 文件上传到该文件夹以运行代码。
任何帮助将不胜感激!提前致谢。
library(shiny)
SpadeFiles <- dir("SampleDataFolder", recursive = TRUE, pattern = "*.csv", full.names = TRUE) #load .csv files from within "SampleDataFolder"
SpadeData <- tibble(filename=SpadeFiles) %>%
mutate(file_contents = map(filename, ~ read_csv(.,skip=3,col_names = c("time", "torque"),
col_types = cols_only(col_double(),col_double(),col_skip(),col_skip())))) #mutate file contents
FullSpade <- unnest(SpadeData, cols = c(file_contents)) #unnest file contents
FullSpade <- separate(FullSpade, filename,sep = "/",into = c("folder","sample_id")) #separate path info into multiple columns
UnqSI <- unique(FullSpade[c("sample_id")]) #create a df of the unique sample_ids
UnqSI[sapply(UnqSI, is.character)] <- lapply(UnqSI[sapply(UnqSI, is.character)], as.factor) #make the UnqSI a df of factors
UnqSI <- as.data.frame(UnqSI) #make sure the df is a df
ui <- fluidPage(
selectInput("ds", "Please select a dataset: ", choices = UnqSI),
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
光标在下拉栏中闪烁,但无论我点击哪里,我都无法看到或选择下拉菜单。
解决方案
推荐阅读
- nsight - NVidia NSight 看不到着色器资源名称 (DX12)
- javascript - 如何从下面的模板中删除 Blooger 帖子片段代码
- python-3.x - 安全地交换公共 dsa 密钥以在 python 中手动使用
- python - 如何在数据帧(python/pandas)中将日期时间(YYYY-MM-DD HH-MM-SS)缩短为年月(YYYY-MM)
- c# - 有没有办法创建分配给退出表单窗口的缩放图像
- javascript - 为什么双击在 Iphone 上不起作用
- python - 为什么 time.sleep() 一次发生而不是一次发生?
- python - 如何缩进Python中for循环产生的打印输出?
- swift - Swiftui - 蓝牙低功耗状态始终未知
- php - 会话 [(null externalkey)] 不可用且不在最后 1000 个终止会话中。活动会话是[ext。键 2a7...]