Skip to content

Instantly share code, notes, and snippets.

@benjamin-chan
Created June 26, 2026 17:28
Show Gist options
  • Select an option

  • Save benjamin-chan/5c9c8dc3c66436de1978cd4496ea2ebc to your computer and use it in GitHub Desktop.

Select an option

Save benjamin-chan/5c9c8dc3c66436de1978cd4496ea2ebc to your computer and use it in GitHub Desktop.
R function to select rows in a data frame whose columns are not all NA
# Function to select rows in a data frame whose columns are not all NA
selectNotAllNA <- function(data) {
require(dplyr)
require(tidyselect)
foo <- function(x) {any(!is.na(x))}
data |> select(where(foo))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment