Reputation: 17
Trying to pass a reactive value into the dirname() function in R/Shiny. Getting error: Error in dirname: a character vector argument expected
I setup reactiveValues like this:
server <- function(input, output, session) {
v = reactiveValues(root = '/path', files = NULL, folders = NULL)
I then have a button press observeEvent:
observeEvent(input$Btn, {
v$files <<- grep("stuff", list.files(path = files.path(v$root), recursive=T, pattern=".py"))
v$folders <<- dirname(v$files)
})
Why won't dirname accept the reactive value "v$files" as an argument? and how can I get it so it does accept it?
Upvotes: 0
Views: 206
Reputation: 17
As mentioned by Aurèle, The missing value=T argument in the grep was causing the issue. Adding that gave me the intended result.
grep("stuff", list.files(path = files.path(v$root), recursive=T, pattern=".py"), invert=T, value=T)
Also pointed out by Aurèle, I switched the assignments to single arrow since double is not necessary when using reactive values it seems.
Upvotes: 0