remove_na_safe {Rapi} | R Documentation |
remove_na_safe
Description
This function removes rows from both ends of a data frame until it identifies a row where all columns have non-NA values. Starting from the beginning, it removes rows until it encounters a row with complete data at a specific row index (e.g., row 5). It then proceeds to remove rows from the end of the data frame, eliminating any rows with at least one NA value in any column. The process stops when it finds a row where all columns contain non-NA values, and the resulting data frame is returned.
Usage
remove_na_safe(df , verbose = FALSE )
Arguments
df |
data.frame to remove na rows from the beginning and from the end |
verbose |
give detailed info while removing NA values |
Value
data.frame returns data.frame after removing rows if all columns are NA from the beginning and after
Examples
df <- data.frame(
a = c(NA, 2:7, NA),
b = c(NA, NA, 5, NA, 12, NA, 8, 9)
)
df2 <- remove_na_safe(df)
[Package Rapi version 1.0.5 Index]