d3treemap error in Rshiny

Hi, I wanted to plot an interactive treemap in Rshiny based on the values of 2 categorical inputs. But I always receive an error Error in if: the condition has length > 1 and the output will not show.

Below is my dput datatable i use to call inside the rshiny function:

dput(head(`Participant_Details(880)`))
structure(list(`Participant ID` = c(0, 1, 2, 3, 4, 5), InteractionCount = c(987L, 
7950L, 7692L, 4407L, 13885L, 12038L), `Household Size` = c(3, 
3, 3, 3, 3, 3), `Have Kids` = c(TRUE, TRUE, TRUE, TRUE, TRUE, 
TRUE), Age = c(36, 25, 35, 21, 43, 32), `Education Level` = c("High School or College", 
"High School or College", "High School or College", "High School or College", 
"Bachelors", "High School or College"), `Interest Group` = c("H", 
"B", "A", "I", "H", "D"), `Age Group` = c("36-40", "21-25", "31-35", 
"21-25", "41-45", "31-35"), `Income Level` = c("High Income", 
"High Income", "High Income", "High Income", "High Income", "Low Income"
), `Joviality Level` = c("Dull Participant", "Average Participant", 
"Average Participant", "Dull Participant", "Happy Participant", 
"Average Participant"), Type = c("Resident", "Resident", "Resident", 
"Resident", "Resident", "Resident"), Region = c("North-west", 
"Central", "South", "Central", "East", "South"), `Workplace ID` = c(424, 
1321, 440, 436, 411, 385)), row.names = c(NA, -6L), class = c("tbl_df", 
"tbl", "data.frame"))

I use two select input to decide which category to be called inside the treemap

fluidRow(
                  column (3,
                              helpText(" Visualise the Social Network Interaction of the Population in Ohio"),
                              selectInput(inputId = "social_category",
                                          label = "Choose a Category",
                                          choices = c( "Household Size",
                                                       "Have Kids",
                                                       "Education Level",
                                                       "Interest Group",
                                                       "Age Group"
                                          ),
                                          selected = "Household Size"),
                              
                              selectInput(inputId = "social_category1",
                                          label = "Choose 2nd Category",
                                          choices = c( "Household Size",
                                                       "Have Kids",
                                                       "Education Level",
                                                       "Interest Group",
                                                       "Age Group"
                                          ),
                                          selected = "Age Group")
                              
                  
                ),
                
                column (6,
                        d3treeOutput("treemapPlot"),
                        )
      ),

Any my output is as such:

output$treemapPlot <- renderD3tree3({
     d3tree3(
       treemap(Participant_Details,
               index = c(input$social_category, input$social_category1),
               vSize = "InteractionCount",
               type = "value",
               vColor = "InteractionCount",
               palette="Set2",
               title="Interaction Count of Participant",
               title.legend = "Interaction Count"
       ), 
       rootname = "Tree Map of Interaction Count by Participant"
     )
   })

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.