| obsedele | R Documentation |
Delete observations with excessive consecutive missing values
obsedele(
data,
cols = NULL,
group = NULL,
by = "min",
half = 30,
date_col = NULL,
cores = NULL,
verbose = FALSE
)
data |
A data frame. |
cols |
Columns to check. If |
group |
Optional grouping column. |
by |
Time unit used only to validate the internal |
half |
Half window size in minutes. |
date_col |
Time column. |
cores |
Number of CPU cores. |
verbose |
Logical. |
For every missing value in each selected column, the C++ backend
computes the time distance to the nearest non-missing anchor on the
left and on the right. A row is deleted when any selected column has both
distances exceed half minutes. When a run touches the series
boundary, the missing side is treated as +Inf, so boundary
rows are only deleted when the surviving side is also too far away.
This is a change from dataprep 0.1.5, which collapsed all selected
columns into one long vector before computing missing runs. The old
approach merged NA runs across columns and over-deleted boundary
rows. See vignette("dataprep-migration") for the upgrade
guide.
A data frame with rows removed.
The comparison is inclusive: if an anchor is exactly half
minutes away, the row is retained. On the SMEAR I Varrio 2025
full-year dataset this rule retains three rows that 0.1.5 removed.
Chun-Sheng Liang <chun-shengliang@qq.com>
1. Example data is from https://smear.avaa.csc.fi/download. It includes particle number concentrations in SMEAR I Varrio forest.
varidele, condextr,
na_diagnose, dataprep.
df <- data.frame(
date = as.POSIXct("2024-01-01 00:00:00", tz = "UTC") + 0:9 * 600,
group = rep(1L, 10),
x = c(1, NA, NA, NA, 5, NA, NA, 2, NA, 3)
)
obsedele(df, cols = "x", group = "group", half = 30)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.