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:
library(flextable)
library(dplyr)
library(tidyr)
library(purrr)
library(ggplot2)
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)) +
theme_void()
list(p)
}
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
))) %>%
autofit()
ft
Related Topics
How to Control Ordering of Stacked Bar Chart Using Identity on Ggplot2
Split an Audio File into Pieces of an Arbitrary Size
Combing a Categorical Variable to Create a New Categorical Variable in R
Conditional Replacement of a Comma With a Dot in a Numeric Column
Error in Confusion Matrix:The Data and Reference Factors Must Have the Same Number of Levels
How to Change the Spacing Between Legend Items in Ggplot2
Add Legend to Geom_Line() Graph in R
How to Change the Default Colors in Plotly Chart
Removing All Empty Columns and Rows in Data.Frame When Rows Don't Go Away
Add Column Values Based on Other Columns in Data Frame Using for and If
Error in Confusionmatrix the Data and Reference Factors Must Have the Same Number of Levels
Find Duplicated Elements With Dplyr
Mapping Columns/Rows from One Dataframe to Another Based on Row Number
Using Ggplot2, How to Insert a Break in the Axis
Ggplot2 Stacked Bar Chart - Each Bar Being 100% and With Percenage Labels Inside Each Bar
Multiplying All Columns in Dataframe by Single Column