restrict_to_country | R Documentation |
Restricts a dataset to one or more countries, specified by their names. If you have lon/lat data and don't know
which countries these coordinates belong to, see add_country_names
. Can restrict data to a rectangle around a given country
as well (usually looks nicer for plotting).
restrict_to_country(dt, ct, rectangle = FALSE, tol = 1)
dt |
the data table. |
ct |
name of the country, or vector containing multiple country names |
rectangle |
logical. If FALSE (default), the data is restricted to the gridcells for which the centerpoint lies within the selected country (e.g. for computing mean scores for a country). If TRUE, the data is kept for a rectangle containing the entire country, therefore also containing gridpoints outside the country. This is the preferred option for plotting data for a specific country. |
tol |
Only used when |
the data table, restricted to the selected country
# example data:
ex_dt = chirps_monthly[lat < 0 & month == 11 & year == 2020]
dt = restrict_to_country(ex_dt,'Kenya')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.