Remove columns from dataframe where ALL values are NA
To remove columns with na in r where all values are NA, you can use the select_if function from the dplyr package as follows: df df x y z 1 1 1 NA 2 2 2 NA 3 3 NA NA 4 4 4 NA 5 5 5 NA 6 6 NA NA 7 7 7 NA 8 8 8 NA 9 9 4 NA 10 10 NA NA To remove column ‘z’(All NA’s):library(dplyr) all_na % select_if(all_na) x y 1 1 1 2 2…
Answered Jul 15, 2021 · 1 Views Read answer →