This is a very basic use of subset
.
data |> subset(ex != 0 | is.na(ex))
Output:
#> ex
#> 1 2
#> 2 2
#> 3 NA
#> 4 NA
#> 6 1
#> 8 NA
#> 9 2
#> 10 3
PS – create reproducible example
data <- structure(list(ex = c(2, 2, NA, NA, 0, 1, 0, NA, 2, 3)),
class = "data.frame", row.names = c(NA, -10L))
data
#> ex
#> 1 2
#> 2 2
#> 3 NA
#> 4 NA
#> 5 0
#> 6 1
#> 7 0
#> 8 NA
#> 9 2
#> 10 3
Created on 2022-06-13 by the reprex package (v2.0.1)
0
solved My dataframe i changing when dropping observations conditionaly