wordcloudLayer: Wordcloud Layer

View source: R/wordcloudLayer.R

wordcloudLayerR Documentation

Wordcloud Layer

Description

Plot a word cloud adjusted to an sf object.

Usage

wordcloudLayer(
  x,
  txt,
  freq,
  max.words = NULL,
  cex.maxmin = c(1, 0.5),
  rot.per = 0.1,
  col = NULL,
  fittopol = FALSE,
  use.rank = FALSE,
  add = FALSE,
  breaks = NULL,
  method = "quantile",
  nclass = NULL
)

Arguments

x

an sf object, a simple feature collection (POLYGON or MULTIPOLYGON).

txt

labels variable.

freq

frequencies of txt.

max.words

Maximum number of words to be plotted. least frequent terms dropped

cex.maxmin

integer (for same size in all txt) or vector of length 2 indicating the range of the size of the words.

rot.per

proportion words with 90 degree rotation

col

color or vector of colors words from least to most frequent

fittopol

logical. If true would override rot.per for some elements of x

use.rank

logical. If true rank of frequencies is used instead of real frequencies.

add

whether to add the layer to an existing plot (TRUE) or not (FALSE)

breaks, method, nclass

additional arguments for adjusting the colors of txt, see choroLayer.

Author(s)

dieghernan, https://github.com/dieghernan/

References

Ian Fellows (2018). wordcloud: Word Clouds.

R package version 2.6. https://CRAN.R-project.org/package=wordcloud

See Also

choroLayer, legendChoro

Examples

library(sf) 
mtq <- st_read(system.file("gpkg/mtq.gpkg", package = "cartography"))
par(mar=c(0,0,0,0))
plot(st_geometry(mtq),
     col = "white",
     bg = "grey95",
     border = NA)
wordcloudLayer(
  x = mtq,
  txt = "LIBGEO",
  freq = "POP",
  add = TRUE,
  nclass = 5
)
legendChoro(
  title.txt = "Population",
  breaks = getBreaks(mtq$POP, nclass = 5, method = "quantile"),
  col = carto.pal("blue.pal", 5),
  nodata = FALSE
)

cartography documentation built on Sept. 14, 2023, 5:08 p.m.