It is common to want to remove cases/rows where all variables in a particular set are missing, e.g. all symptom variables are missing in a health care dataset.

rm_empty_block(.data, ...)

Arguments

.data

Dataframe.

...

Unquoted variable/column names.

Value

Data frame.

Examples

# Pretend that we want to remove rows that are missing in group1, group2, and group3 
# but keep rest of dataset. 
colon_s %>% 
  dplyr::mutate(
    group1 = rep(c(NA, 1), length.out = 929),
    group2 = rep(c(NA, 1), length.out = 929),
   group3 = rep(c(NA, 1), length.out = 929)
  ) %>% 
rm_empty_block(group1, group2, group3) %>% 
  head()
#>    id      rx sex age obstruct perfor adhere nodes status differ extent surg
#> 2   2 Lev+5FU   1  63        0      0      0     1      0      2      3    0
#> 4   4 Lev+5FU   0  66        1      0      0     6      1      2      3    1
#> 6   6 Lev+5FU   0  57        0      0      0     9      1      2      3    0
#> 8   8     Obs   1  54        0      0      0     1      0      2      3    0
#> 10 10 Lev+5FU   0  68        0      0      0     1      0      2      3    1
#> 12 12 Lev+5FU   1  52        0      0      0     2      0      3      3    1
#>    node4 time sex.factor rx.factor obstruct.factor perfor.factor adhere.factor
#> 2      0 3087       Male   Lev+5FU              No            No            No
#> 4      1  293     Female   Lev+5FU             Yes            No            No
#> 6      1 1767     Female   Lev+5FU              No            No            No
#> 8      0 3192       Male       Obs              No            No            No
#> 10     0 3308     Female   Lev+5FU              No            No            No
#> 12     0 3309       Male   Lev+5FU              No            No            No
#>    differ.factor extent.factor surg.factor node4.factor status.factor
#> 2       Moderate        Serosa       Short           No         Alive
#> 4       Moderate        Serosa        Long          Yes          Died
#> 6       Moderate        Serosa       Short          Yes          Died
#> 8       Moderate        Serosa       Short           No         Alive
#> 10      Moderate        Serosa        Long           No         Alive
#> 12          Poor        Serosa        Long           No         Alive
#>     age.factor loccomp loccomp.factor time.years mort_5yr age.10 mort_5yr.num
#> 2    60+ years       0             No  8.4575342    Alive    6.3            1
#> 4    60+ years       1            Yes  0.8027397     Died    6.6            2
#> 6  40-59 years       0             No  4.8410959     Died    5.7            2
#> 8  40-59 years       0             No  8.7452055    Alive    5.4            1
#> 10   60+ years       0             No  9.0630137    Alive    6.8            1
#> 12 40-59 years       0             No  9.0657534    Alive    5.2            1
#>      hospital group1 group2 group3
#> 2  hospital_3      1      1      1
#> 4  hospital_4      1      1      1
#> 6  hospital_4      1      1      1
#> 8  hospital_2      1      1      1
#> 10 hospital_2      1      1      1
#> 12 hospital_1      1      1      1