I'm trying to select a sample of data using selectInput. I'd like to build a dropdown menu of the specific sample_ids in my dataframe, and use that to subset that sample id from a larger dataframe to graph later. However, I'm unable to correctly build this dropdown menu.
Download the two sample files here
Create a folder in your working directory named "SampleDataFolder" and upload the .csv files to this folder to run the code.
Any help would be greatly appreciated! Thanks in advance.
library(shiny)
library(tidyverse)
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)
An image of my workspace and the app while it is running is attached. The cursor flashes in the dropdown bar, but I am unable to see or select the dropdown no matter where I click.