| bru_fill_missing | R Documentation |
Computes nearest-available-value imputation for missing values in space
bru_fill_missing(
data,
where,
values,
layer = NULL,
selector = NULL,
batch_size = deprecated()
)
An infilled vector of values
## Not run:
if (require("sf", quietly = TRUE)) {
points <-
sf::st_as_sf(
data.frame(
x = 1:3,
y = 4:6,
val = c(NA, NA, NA)
),
coords = c("x", "y")
)
input_coord <- expand.grid(x = 0:7, y = 0:7)
input <-
sf::st_as_sf(
cbind(input_coord, val = as.vector(input_coord$y)),
coords = c("x", "y")
)
points$val <- bru_fill_missing(input, points, points$val)
print(points)
# To fill in missing values in a grid:
print(input$val[c(3, 30)])
input$val[c(3, 30)] <- NA # Introduce missing values
input$val <- bru_fill_missing(input, input, input$val)
print(input$val[c(3, 30)])
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.