Remove columns from dataframe where some of values are NA

前端 未结 7 1399
小鲜肉
小鲜肉 2020-11-28 08:32

I have a dataframe where some of the values are NA. I would like to remove these columns.

My data.frame looks like this

    v1   v2 
1    1   NA 
2           


        
7条回答
  •  情书的邮戳
    2020-11-28 09:14

    Here's a convenient way to do it using the dplyr function select_if(). Combine not (!), any() and is.na(), which is equivalent to selecting all columns that don't contain any NA values.

    library(dplyr)
    Itun %>%
        select_if(~ !any(is.na(.)))
    

提交回复
热议问题