1

Since select_if is superseded, I wanna know the "not superseded/tidyverse" version of:

library(tidyverse)
library(ggplot2movies)
library(purrr)

movies %>%
  select_if(~ sum(is.na(.))/length(.) > .25)

Another option that works is:

movies %>% 
  keep(~ sum(is.na(.x))/length(.x) > .25)

2
  • Can you provide a MWE? (data and desired output) Commented Mar 11, 2021 at 22:59
  • @AdamK movies data is from ggplot2movies Commented Mar 11, 2021 at 23:11

1 Answer 1

1

We can use select with where

library(dplyr) # // version 1.0.4
library(ggplot2movies)
out2 <- movies %>%
   select(where(~ mean(is.na(.)) > .25))

-checking with OP's code

out1 <- movies %>%
         select_if(~ sum(is.na(.))/length(.) > .25)

identical(out1, out2)
#[1] TRUE

sum(...)/n() can be mean(...)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.