Why are my rendered tabsetPanel plots being cut off in flexdashboard?

I am new to flexdashboard and shiny in general, but when I try to use the tabsetPanel function, the plots and maps I want to show render where I expect them to with the information I expected, but the size is completely off in that the bottoms are squished. Here is a picture of what I mean: https://i.stack.imgur.com/wL4OK.png. Any help would be greatly appreciated!

Here is the code I am using:

Worcester_income <- read.csv("/Users/abigaildrummond/Desktop/TIGOR/Worcester MA Datasets/Selected Economic Characteristics/Selected Economic Characteristics.csv") %>% select(GEO_ID, NAME, DP03_0062E) %>% rename("Median_Household_Income" = "DP03_0062E", "GEOID" = "GEO_ID")
Worcester_income$GEOID <- as.character(Worcester_income$GEOID)
Worcester_income$Median_Household_Income <- as.numeric(Worcester_income$Median_Household_Income)
Worcester_income <- Worcester_income[-c(1),]

geocoded_Worcester_income <- merge(Worcester_census_tracts, Worcester_income, by="GEOID")

## racial breakdown using boxplots
Worcester_income_byrace <- read.csv("/Users/abigaildrummond/Desktop/TIGOR/Worcester MA Datasets/Income/Income.csv") %>% select(BLACK, AMIN_NAK, ASIAN, NH_PI, OTHER, TWOPLUS, HISPANIC, WHITE)
Worcester_income_byrace <- Worcester_income_byrace[-c(1),]
Worcester_income_byrace[,1:8] <- sapply(Worcester_income_byrace[,1:8], as.numeric)

Worcester_income_byrace <- Worcester_income_byrace %>% pivot_longer(BLACK:WHITE, names_to = "race", values_to = "median_income")

## put it all together!
ui_income <- fluidPage(
  tabsetPanel(
    tabPanel("Median Household Income", tmapOutput("income_map")),
    tabPanel("Race/Ethnicity Breakdown", plotlyOutput("income_plot")),
    tabPanel("Income Inequality",plotlyOutput("GINI")
)))

server_income <- function(input, output){
  output$income_map <- renderTmap({
      tm_shape(geocoded_Worcester_income) +
  tm_fill(col= "Median_Household_Income", style= "cont", popup.vars = c("Census Tract:" = "GEOID", "Median Household Income:" = "Median_Household_Income"), title="Dollars") +
  tm_borders()
    })
    
    output$income_plot <- renderPlotly(
      ggplotly(
  ggplot(data=Worcester_income_byrace) +
  geom_boxplot(aes(x= race, y=median_income, fill=race)) +
  scale_x_discrete(limits= c("WHITE", "BLACK", "ASIAN", "HISPANIC", "OTHER", "TWOPLUS"), labels=c("White", "Black", "Asian", "Hispanic", "Other", "Two or More")) +
    theme_minimal() +
    theme(legend.position ="none") +
  labs(title = "Median Household Income by Race, 2019 Estimate", x= "Race or Ethnicity", y="Median Household Income ($)")
)

    )
    
    output$GINI <- renderPlotly(
      ggplotly(
ggplot(Worcester_income, aes(Median_Household_Income)) +
  stat_lorenz() +
  geom_abline(linetype = "dashed") +
  annotate_ineq(Worcester_income$Median_Household_Income) +
  theme_minimal() +
  hrbrthemes::scale_x_percent() +
    hrbrthemes::scale_y_percent() +
  labs(title= "Lorenz Curve", x="Cumulative Share of Census Tracts", y="Cumulative Share of Income")
) 
    )
} 

shinyApp(ui = ui_income, server = server_income)

This wasn't happening before but I don't know how to solve it. Thanks.

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.