I am using Shiny together with RMarkdown to produce an interactive document, as described here.
Using the following code, I managed to plot an interactive map
```{r, echo=FALSE, warning=FALSE, message=FALSE}
g2g14 <- readOGR("input//geodata", "g2g14") # no projection needs to be specified
old_geodata <- g2g14@data
inputPanel(
selectInput("map.party", label = "Partei", choices = unique(long_data$Partei), selected = "FDP"),
selectInput("map.year", label = "Wahljahr", choices = unique(format.Date(long_data$Jahr, "%Y")), selected = "1971")
)
renderPlot({
partydata <- long_data %>%
filter(Partei == input$map.party & Jahr == as.Date(input$map.year, "%Y"))
g2g14@data <- old_geodata
g2g14@data <- merge(g2g14@data, partydata, by.x = "GMDNR",by.y ="BFSNr")
cols <- brewer.pal(5, "Purples")
brks <- seq(0,100,20)
colsForMap <- cols[findInterval(g2g14@data$Staerke, vec = brks[1:5])]
plot(g2g14, col = colsForMap, border = "white")
legend("topleft", legend = levels(cut(g2g14@data$Staerke, brks)), fill = cols, border = "white", title = "Parteistärke in %")
})
The problem: The map is nicely scaled when running the code from the console, but in the interactive document, the plot is too small:
This probably results from the limited height of the plotting region.
I've already tried setting a really large fig.height = 20
in the chunk options, but with no outcome.
What to do?