topFreq: Retrieves the most frequent toponyms

View source: R/top_freq.R

topFreqR Documentation

Retrieves the most frequent toponyms

Description

This function returns the most frequent toponym substrings in countries or a polygon.

Usage

topFreq(countries, len, limit, ...)

Arguments

countries

character string vector with country designations (names or ISO-codes).

len

numeric. The length of the substring within toponyms.

limit

numeric. The number of the most frequent toponym substrings.

...

Additional parameters:

  • type character string. Either by default "$" (ending) or "^" (beginning).

  • feat.class character string vector. Selects data only of those feature classes (check http://download.geonames.org/export/dump/readme.txt for the list of all feature classes). By default, it is P.

  • polygon data frame. Selects toponyms only inside the polygon.

  • toponym_path character string. Path name for downloaded data.

Details

Parameter countries accepts all designations found in country(query = "country table"). Polygons passed through the polygon parameter need to intersect or be within a country specified by the countries parameter. Parameter toponym_path accepts "pkgdir" for the package directory or a full, alternative path. With toponymOptions(), users can specify the path for toponym and map data downloaded by this package across sessions. See help(toponymOptions). The data used is downloaded by getData() and is accessible on the GeoNames download server.

Value

A table with toponym substrings and their frequency.

Examples

## We recommend setting a persistent path for downloaded data by using toponymOptions()
## Users can always set the path manually when a function is used
## For illustration purposes,
## 1. the path is manually set each time
## 2. and wrapped in donttest because data will be downloaded in the following examples:

topFreq(
  countries = "Ecuador",
  len = 3,
  limit = 10,
  toponym_path = tempdir())
## returns the top 10 most frequent toponym endings
## of three-character length in Ecuador



topFreq(
  countries = "GB",
  len = 3,
  limit = 10,
  polygon = toponym::danelaw_polygon,
  toponym_path = tempdir())
## returns the top 10 most frequent toponym endings
## in the polygon which is inside the United Kingdom.


toponym documentation built on April 13, 2026, 5:06 p.m.