delete.na <- function(DF, n=0) { DF[rowSums(is.na(DF)) <= n,] } code example
Example: r remove na from dataset
new_df <- na.omit(df, c("myvar1", "myvar2")) # Remove NA on specific variables
new_df <- na.omit(df, c("myvar1", "myvar2")) # Remove NA on specific variables