Using the code provided in the flexdashboard documentation, I have tried to reproduce the error that I'm getting. In attempting to solve this question, I've reviewed Flexdashboard - leaflet not full screen.
As a second avenue to understanding the problem, the "worldPhones" inline code was posted and returned with "Error: figure margins too large." In attempting to solve that error, the question, Error in plot.new() : figure margins too large, Scatter plot was consulted. (Maybe, a better title would have been: Why can't I write an inline shiny app and have it work in a flexdashboard?)
The code that produces a "short" leaflet map and an error for the worldPhones is the following:
---
title: "Demo"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(leaflet)
```
Column {data-width=650}
-----------------------------------------------------------------------
### Leaflet Map Inline -- Height constrained
```{r inline-leaflet-map}
shinyApp(
ui = leafletOutput("map", height = 800),
#ui = leafletOutput("map", height = "100%")
server = function(input, output){
output$map <- renderLeaflet({
leaflet() |>
setView(-86.457, 38.564, zoom = 9) |>
addTiles()
})
}
)
```
Column {data-width=350}
-----------------------------------------------------------------------
### Inline World Phones -- "Error: figure margins too large"
```{r inline-world-phones}
shinyApp(
ui = fillPage(
fillCol(flex = c(NA, 1),
inputPanel(
selectInput("region", "Region:", choices = colnames(WorldPhones))
),
plotOutput("phonePlot", height = "100%")
)
),
server = function(input, output) {
output$phonePlot <- renderPlot({
barplot(WorldPhones[,input$region]*1000,
ylab = "Number of Telephones", xlab = "Year")
})
},
options = list(height = 600)
)
```
### Fill Layout -- This works
```{r fill-layout-worldphones}
fillCol(height = 600, flex = c(NA, 1),
inputPanel(
selectInput("region", "Region:", choices = colnames(WorldPhones))
),
plotOutput("phonePlot", height = "100%")
)
output$phonePlot <- renderPlot({
barplot(WorldPhones[,input$region]*1000,
ylab = "Number of Telephones", xlab = "Year")
})
```
When the code is run, it produces the following dashboard: