esquisse icon indicating copy to clipboard operation
esquisse copied to clipboard

Error when using n_geoms = 1

Open williamorim opened this issue 7 months ago • 2 comments

Setting n_geoms = 1 in esquisse_ui() leads to the following error when dragging any variable into the Y axis.

Warning: Error in if: missing value where TRUE/FALSE needed
  3: runApp
  2: print.shiny.appobj
  1: <Anonymous>

Tested with the following minimal example using esquisse 2.0.0:

library(esquisse)
library(shiny)
library(ggplot2)

ui <- fluidPage(
  
  titlePanel("Use esquisse as a Shiny module"),
  
  sidebarLayout(
    sidebarPanel(
      radioButtons(
        inputId = "data", 
        label = "Select data to use:", 
        choices = c("mpg", "diamonds", "economics")
      )
    ),
    mainPanel(
      tabsetPanel(
        tabPanel(
          title = "esquisse",
          esquisse_ui(
            id = "esquisse", 
            n_geoms = 1,
            header = FALSE # dont display gadget title
          )
        ),
        tabPanel(
          title = "output",
          tags$b("Code:"),
          verbatimTextOutput("code"),
          tags$b("Filters:"),
          verbatimTextOutput("filters"),
          tags$b("Data:"),
          verbatimTextOutput("data")
        )
      )
    )
  )
)


server <- function(input, output, session) {
  
  data_r <- reactiveValues(data = iris, name = "iris")
  
  observe({
    data_r$data <- get(input$data)
    data_r$name <- input$data
  })
  
  results <- esquisse_server(
    id = "esquisse",
    data_rv = data_r
  )
  
  output$code <- renderPrint({
    results$code_plot
  })
  
  output$filters <- renderPrint({
    results$code_filters
  })
  
  output$data <- renderPrint({
    str(results$data)
  })
  
}

shinyApp(ui, server)

My system

> R.version
               _                           
platform       aarch64-apple-darwin20      
arch           aarch64                     
os             darwin20                    
system         aarch64, darwin20           
status                                     
major          4                           
minor          3.2                         
year           2023                        
month          10                          
day            31                          
svn rev        85441                       
language       R                           
version.string R version 4.3.2 (2023-10-31)
nickname       Eye Holes

williamorim avatar Jul 04 '24 17:07 williamorim