Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev ggplot2 appears to break thematic #6317

Closed
olivroy opened this issue Jan 31, 2025 · 2 comments · May be fixed by rstudio/thematic#156
Closed

dev ggplot2 appears to break thematic #6317

olivroy opened this issue Jan 31, 2025 · 2 comments · May be fixed by rstudio/thematic#156

Comments

@olivroy
Copy link
Contributor

olivroy commented Jan 31, 2025

Here is my shiny app. Don't really know how to reproduce without shiny (which makes it hard to debug)

I had to do a GitHub search for Internal error: adjust_color() expects an input of length 1 to figure out where this was coming from...

library(shiny)
library(bslib)
library(thematic)
library(ggplot2)

thematic::thematic_shiny()

# Define UI
ui <- fluidPage(
  theme = bs_theme(version = 5, bootswatch = "minty"),

  titlePanel("Shiny App with bslib, thematic, and ggplot2"),

  sidebarLayout(
    sidebarPanel(
      selectInput("dataset", "Choose a dataset:",
                  choices = c("mtcars", "iris")),
      uiOutput("var_select")
    ),

    mainPanel(
      plotOutput("plot")
    )
  )
)

# Define server logic
server <- function(input, output, session) {

  datasetInput <- reactive({
    switch(input$dataset,
           "mtcars" = mtcars,
           "iris" = iris)
  })

  output$var_select <- renderUI({
    req(datasetInput())
    selectInput("variable", "Choose a variable:",
                choices = names(datasetInput()))
  })

  output$plot <- renderPlot({
    req(input$variable)
    ggplot(datasetInput(), aes({{ input$variable }})) +
      geom_histogram(fill = "blue", bins = 20, alpha = 0.7) +
      theme_minimal()
  })
}

# Run the application
shinyApp(ui = ui, server = server)

(app from ChatGPT)

Backtrace

Avis : Error in adjust_color: Internal error: adjust_color() expects an input of length 1
  189: stop
  188: adjust_color
  185: <Anonymous>
  184: mapply
  183: Map
  182: ggplot_build.ggplot
  180: print.ggplot
  175: func
  173: f
  172: Reduce
  163: do
  162: hybrid_chain
  134: drawPlot
  120: <reactive:plotObj>
  100: drawReactive
   87: renderFunc
   86: output$plot
    1: runApp

https://github.com/rstudio/thematic/blob/76513a7ad671257545e34381fc6ab47e8c5eaa80/R/utils.R#L5

(This works as expected with CRAN ggplot2)

@teunbrand
Copy link
Collaborator

Thanks for the report @olivroy! The thematic package is on our radar due to revdepchecks, but we've not settled on a resolution yet.

@teunbrand
Copy link
Collaborator

Let's track this in rstudio/thematic#156, so we can close this here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants