I have the following data frame which I create after a count:
df <- structure(list(Procedure_priority = structure(c(4L, 1L, 2L, 3L, NA, 5L),
.Label = c("A", "B", "C", "D", "-1"),
class = "factor"), n = c(10717L, 4412L, 2058L, 1480L, 323L, 2L)),
class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -6L), .Names = c("Procedure", "n"))
# A tibble: 6 x 2
Procedure n
<fct> <int>
1 D 10717
2 A 4412
3 B 2058
4 C 1480
5 <NA> 323
6 -1 2
I want to filter the "-1". But if I make a filter on "-1" I also loose my NA. That is:
df %>%
filter(Procedure!="-1")
# A tibble: 4 x 2
Procedure n
<fct> <int>
1 D 10717
2 A 4412
3 B 2058
4 C 1480
I need my NA's.