Reputation: 21
I'm trying to build a reporting system for exploratory analytics in R/shiny, and find the interactive documents feature especially attractive. Unfortunately, the interactive document templates seem to require you to know the nature of the input data already. What I'd like to be able to do is to have a config file which I modify for the individual reports, but leave the actual report Rmarkdown script alone. This is what I currently have:
parameters.R:
file_directory <- "/ngsdata/intern/projects/Exomes/vcfs/"
files <- c(
"s38499.toprocess.tsv",
"s38626.toprocess.tsv",
"s38600.toprocess.tsv"
)
files <- paste0(file_directory,files)
sampleNames <- c("38499","38626","38600")
My Rmd file:
checkBoxList <- paste("checkbox",sampleNames,sep="_")
for (i in 1:length(sampleNames)) {
checkboxInput(checkBoxList[i], label = sampleNames[i], value=TRUE)
}
checkboxInput("38499", label = "my label", value=TRUE)
None of the checkboxes in the for loop are displayed when I click "Run Document" in Rstudio, but the last one ("my label") does get displayed.
Any tips for how I can base the number of checkboxes on the contents of the parameters.R file instead of modifying the Rmd file?
Upvotes: 1
Views: 194
Reputation: 21
After some digging around, I found a solution for me:
mylist <- as.list(1:length(sampleNames))
names(mylist) <- sampleNames
checkboxGroupInput("mygroup",label=h3("samples"),choices=mylist,selected=1:length(sampleNames))
Upvotes: 1