In RStudio I try to knit my code which produces a map into html-file and get in compiled html-file besides a map an undesired message:
"## Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3".
This message is produced by the function tm_shape()
which plots a map from tmap
library.
I tried to surround construction with tm_shape()
function by the construction invisible(capture.output(...))
. It doesn't work.
I also tried to execute the function tmap_options(show.messages = FALSE)
before calling tm_shape()
. It doesn't work.
suppressPackageStartupMessages(library(rgdal))
suppressPackageStartupMessages(library(tmap))
tmap_options(show.messages = FALSE)
invisible(capture.output(area = readOGR("adm1.shp")))
area@data$VARNAME_1 = as.character(area@data$VARNAME_1)
suppressPackageStartupMessages(library(dplyr))
area@data = left_join(area@data, df, by = c("VARNAME_1" = "Area"))
tm_shape(area) + tm_fill("x", style = "fixed", palette = "Greens", breaks = c(0,10,20,30,40,50), labels = c("0-10", "10-20", "20-30", "30-40", "40-50")) + tm_legend(text.size = 1) + tm_layout(legend.position = c("left", "bottom")) + tm_borders("grey") + tm_layout(frame = F)
So, the question is how to suppress this undesired message?