bangen
November 3, 2020, 7:46pm
1
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
cderv
November 4, 2020, 8:23am
2
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:
opened 11:25PM - 26 Apr 19 UTC
closed 01:55AM - 15 Feb 22 UTC
bug
reproducible
stale
### System details
RStudio Edition : Desktop
RStudio Version : 1.2.1… 335
OS Version : macOS 10.14.4
R Version : 3.5.2
### Steps to reproduce the problem
The following Shiny application displays a file chooser:
```R
library(shiny)
ui <- fluidPage(
fileInput("fileChooser", "Upload a Processed File", accept = "text/plain")
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
```
In the RStudio browser file chooser dialog, files of every type can be chosen. In the other browsers I've tested (Firefox 66 macOS, Chrome 73 macOS) only `text/plain` files can be chosen.
### Describe the problem in detail
The RStudio browser's file chooser dialog does not appear to respect the `accept` MIME type, as other browsers appear to.
### Describe the behavior you expected
I would expect the RStudio browser to behave the same way as Firefox and Chrome.
Note that this issue was originally reported by @DarioS at https://github.com/rstudio/shiny/issues/951
originally from here
opened 08:00AM - 10 Sep 15 UTC
closed 11:26PM - 26 Apr 19 UTC
For example, I use `fileInput("fileChooser", "Upload a Processed File", accept =… "text/plain")` but the file chooser shows all types of files. Also, the documentation should explicitly state what MIME value to provide for `RData` files. I can't find that extension in the [MIME type list](http://www.sitepoint.com/web-foundations/mime-types-complete-list/).
bangen
November 4, 2020, 9:45pm
3
We don't have a RStudio Connect license. So the issue is in the RStudio IDE when running Knit with parameters
.
1 Like
cderv
November 4, 2020, 10:19pm
4
So that means this is related to the one above that is still opened. You can add a to show your interest in it I think.
system
Closed
November 25, 2020, 10:19pm
5
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.