R Markdown param input file type filter

Background
I am putting together a parameterized report *.Rmd for a colleague. It needs to be run in RStudio using Knit with Parameters. Most of the parameters are *.csv and *.xlsx input files.

Issue
I'd like to include a file type filter for the various input files. For example, if the specific input parameter input is a *.csv I'd like the user to only see *.csv files when they select Browse in the Knit with Parameters GUI. So akin to tk_choose.files using filters, but in the yaml.

Section 15.3.3 of RMarkdown guide says:

The type of Shiny control used is controlled by the input field. Table 15.1 shows the input types currently supported (see the help page for the associated Shiny function for additional attributes that can be specified to customize the input, e.g., ?shiny::checkboxInput ).

I tried adding the shiny fileInput accept to the param, but it doesn't filter files.

Does anyone know of a solution or am I out of luck?

Example Code

---
title: "test"
output:
  html_document
params:
  in.csv:
    label: "Input csv:"
    value:
    input: file
    #accept: ".csv" # doesn't work
    
---


```{r}

library(readr)

df = read_csv(params$in.csv, col_names = TRUE, col_types = cols(.default = "c")) 

Relevant session info
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

other attached packages:
[1] readr_1.4.0 shiny_1.5.0

loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 rstudioapi_0.11 knitr_1.30 magrittr_1.5 hms_0.5.3 xtable_1.8-4 R6_2.5.0 rlang_0.4.8 fastmap_1.0.1 tools_4.0.3
[11] xfun_0.19 ellipsis_0.3.1 htmltools_0.5.0 yaml_2.2.1 digest_0.6.27 tibble_3.0.4 lifecycle_0.2.0 crayon_1.3.4 zip_2.1.1 later_1.1.0.1
[21] vctrs_0.3.4 promises_1.1.1 evaluate_0.14 mime_0.9 rmarkdown_2.5 openxlsx_4.2.3 stringi_1.5.3 pillar_1.4.6 compiler_4.0.3 jsonlite_1.7.1
[31] httpuv_1.5.4 pkgconfig_2.0.3

Do you observe this behavior locally or when the document is deployed in the browser ?

I should work in the second case - it does for me when I deploy this document on server like RStudio Connect.

But it does not in RStudio IDE.

I believe this is a know issue:

originally from here

We don't have a RStudio Connect license. So the issue is in the RStudio IDE when running Knit with parameters.

1 Like

So that means this is related to the one above that is still opened. You can add a :+1: to show your interest in it I think.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.