| replace_na.Spat | R Documentation |
NAs with specified valuesReplace NAs values on layers/attributes with specified values
## S3 method for class 'SpatRaster'
replace_na(data, replace = list(), ...)
## S3 method for class 'SpatVector'
replace_na(data, replace, ...)
data |
A |
replace |
A named list of values, with one value for each
layer/attribute that has missing values to be replaced. Each value in
|
... |
Additional arguments for methods. Currently unused. |
A Spat* object of the same class than data. See Methods.
Use r[is.na(r)] <- <replacement>
tidyr::replace_na()
Other tidyr verbs for handling missing values:
drop_na.Spat,
fill.SpatVector()
Other tidyr methods:
drop_na.Spat,
fill.SpatVector(),
pivot_longer.SpatVector(),
pivot_wider.SpatVector()
library(terra)
f <- system.file("extdata/cyl_temp.tif", package = "tidyterra")
r <- rast(f)
r |> plot()
r |>
replace_na(list(tavg_04 = 6, tavg_06 = 20)) |>
plot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.