View source: R/balance_panel.R
| balance_panel | R Documentation |
Transforms an unbalanced panel dataset into a balanced one by either keeping only complete units or filling missing time points with a specified value.
balance_panel(data, unit_col = NULL, time_col = NULL,
fill = NA_real_, method = c("fill", "complete"),
verbose = FALSE)
data |
A data frame containing panel data. |
unit_col |
Column index or name identifying the individual unit (e.g., station ID, subject ID). If |
time_col |
Column index or name identifying the time point. If |
fill |
Value used to fill missing combinations when |
method |
Balancing method: |
verbose |
Logical; if |
The function assumes that the time column is sorted and contains no duplicates within a unit. If duplicates exist, they should be handled beforehand.
A balanced data frame.
balance_panel(data[1:200, c(1, 4, 17:19)], unit_col = 2, time_col = 1, method = "complete")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.