I have a list of dataframes:
DF
LIST <- list(df1 <- data.frame(col_a1 = c("a","b"), col_b2=c(NA,NA)), df2 <- data.frame(col_b2 = c("a","b"), col_b1=c(NA,NA)))
[[1]] col1 col2 1 a NA 2 b NA [[2]] col2 col1 1 a NA 2 b NA
I would like to remove the columns where all entries are NA, and select the ones that contain "1" using pipes
The resulting dataframe list is
[[1]]
cola1
a
b
I would prefer to use pipes to streamline this. The following code is what I've been trying:
LIST %>%
map(~ .x %>% select(contains("1") & !all(is.na(.))))