Error in ≪My Code≫: Object of Type 'Closure' Is Not Subsettable

R Shiny Error: Warning: Error in $: object of type 'closure' is not subsettable

The problem is that you are using df$...... inside the UI. If you define df inside the server function, it is not defined in the UI. So you get this error because R recognizes df as the function provided by the 'stats' package (an object of type "closure" is a function).

R shinyFiles : Warning: Error in [: object of type 'closure' is not subsettable [No stack trace available]

The famous error message "Object of type closure is not subsettable" indicates that you are trying to subset a function. In your case the issue is that getVolumes() returns a function which when called returns a vector of available volumes. To solve your issue change your call of shinyDirChoose like so:

server <- shinyServer(function(input, output) {
volumes = getVolumes()
shinyDirChoose(input, 'folder', roots = volumes())

Flextable error when using gg_chunk(): Error in dots[[1L]][[1L]] : object of type 'closure' is not subsettable

It seems it's an issue with purrr::compose and flextable::compose.

This should work:


df <-
iris %>% select(Species, Petal.Width) %>% group_by(Species) %>% nest(data = c(Petal.Width))

gg <- function(x) {
d <- x %>% mutate(x = row_number()) %>% rename(y = 1)
p <- ggplot(d) +
geom_line(aes(x, y)) +

df_gg <- df %>% mutate(gg = map(data, ~ gg(.x)))

ft <- flextable(data = df_gg) %>%
compose(j = "gg", value = as_paragraph(gg_chunk(
value = gg,
width = 1.5,
height = .4
))) %>%

Sample Image

Related Topics

Leave a reply