dreamRs / esquisse

RStudio add-in to make plots interactively with ggplot2
https://dreamrs.github.io/esquisse
Other
1.78k stars 229 forks source link

Possible bug-> Warning: Error in make.unique: 'names' must be a character vector #164

Closed TestingGround00 closed 3 years ago

TestingGround00 commented 3 years ago

Hello, in the example below I am keep getting the following error-

Warning: Error in make.unique: 'names' must be a character vector
  [No stack trace available]

Whenever, I comment out or remove the components of esquisse, the error goes away. I have looked for this error in stackoverflow and in the web in general, however, I can't pinpoint anything specific. These two discussions match the error I am getting, however, it's from another package (which I am not using, nor I have it installed).

1) https://support.bioconductor.org/p/120543/ 2) https://support.bioconductor.org/p/120686/

options(scipen = 99999, stringsAsFactors = FALSE)
library(shiny)
library(shinyjs)
library(shinyWidgets)
library(DT)
library(dplyr)
#remotes::install_github("dreamRs/esquisse")
library(esquisse)

#dummy df
gen_rep_def <- data.frame(Report = c("iris",
                                     "etc"),
                          Purpose=c("abc",
                                    "xyz"))

ui <- fluidPage(

  shinyjs::useShinyjs(), 

  verbatimTextOutput("value"),

  navbarPage( 

    title= div(HTML("G<em>T</em>")),

    tabPanel("General Reports",

             sidebarLayout(

               sidebarPanel(

                 id = "Sidebar",

                 shinyWidgets::prettyRadioButtons(
                   inputId = "controller",
                   label = "Choose:", 
                   choices = c("About"= 1,
                               "iris"= 2),
                   icon= icon("check"),
                   selected = 1,
                   status = "success",
                   animation="smooth"
                 )
               ),

               mainPanel(
                 id = "main_panel",

                 tabsetPanel(
                   id = "hidden_tabs",
                   type = "hidden",
                   tabPanelBody(
                     "panel1", DT::DTOutput('panel1_data')
                   ),

                   tabPanelBody(
                     "panel2", 
                     tabsetPanel(
                       tabPanel("Data", DT::DTOutput('panel2_data'))
                       ,
                       tabPanel(
                         "Plot",
                         esquisse::esquisse_ui(
                           id = "esquisse2",
                           header = FALSE,
                           container = esquisseContainer(
                             width = "100%", height = "760px", fixed = FALSE
                           ),
                           controls = c("labs", "parameters", "appearance", "filters", "code")
                         )
                       )
                     )
                   )
                 )
               )
             )
    ),

    tags$head(tags$style(HTML('.navbar-brand {width: 270px; font-size:35px; text-align:left;
                              font-family: "serif";')))
  )
)

server <- function(input, output, session) {

  observeEvent(input$controller, {
    print(paste0("You have chosen: ", input$controller))
  })

  # here we put all the data
  data_sets <- list(df1 = gen_rep_def, 
                    df2 = iris)

  data_to_use <- reactiveValues(name = "df", data = data.frame())

  observeEvent(input$controller, {

    updateTabsetPanel(session, inputId= "hidden_tabs", selected = paste0("panel", input$controller))

    req(input$controller)

    data_to_use$data <- data_sets[[as.numeric(input$controller)]]
    data_to_use$name <- names(data_sets[as.numeric(input$controller)])

    observeEvent(input$controller, {
      print(paste0("controller 1 name class: ", class(data_to_use$name)))
    })

    esquisse::esquisse_server(id = "esquisse2", data_rv = data_to_use)

    output[[paste0('panel',  input$controller, '_data')]] <- DT::renderDT(server = FALSE, {
      DT::datatable(data_to_use$data,
                    filter = 'top', 
                    extensions = 'Buttons')})

  })

}

shinyApp(ui= ui, server= server)

There is also this error that gets generated if I have another tabPanel in my navbarPage. Please let me know if interested in seeing a reprex that generated this error-

Warning: Error in make.unique: 'names' must be a character vector
  100: make.unique
   99: makeId
   97: create_filters
   96: renderUI
   95: func
   82: renderFunc
   81: output$esquisse4-controls-filter-data-placeholder_filters
    1: runApp

Thanks :)

taknotts commented 3 years ago

I have the same error running datamods::filter_data_server. The tool seems to work fine but there is an error message on the page in the app when the data for the filter is empty. I have been unsuccessful in identifying how to change my code to remedy the error. I traced it back to utils.R . Thanks!

Warning: Error in make.unique: 'names' must be a character vector
  100: make.unique
   99: makeId
   97: create_filters
   96: renderUI
   95: func
   82: renderFunc
   81: output$filtering-placeholder_filters
    1: runApp
pvictor commented 3 years ago

Thanks, there was indeed a bug in datamods::filter_data_server when using an empty data.frame. Try re-installing from GitHub, this should be fixed.

remotes::install_github("dreamRs/datamods")
remotes::install_github("dreamRs/esquisse")

Victor

TestingGround00 commented 3 years ago

Thanks @pvictor for looking into this :) Appreciate the help as always.