Filter variable where there are existing data in other variable.

filter_cens(x, y)

Arguments

x

Variable to be filtered.

y

Condition variable.

Value

Filtered variable.

Examples

df <- data.frame( cars = 1:3, cars_model = 4:6, cars_speed = 7:9, condition = c(NA, 1, 2) ) dplyr::mutate_at( df, dplyr::vars(dplyr::starts_with("cars")), filter_cens, y = df$condition )
#> cars cars_model cars_speed condition #> 1 NA NA NA NA #> 2 2 5 8 1 #> 3 3 6 9 2