r - How to use or/and in dplyr to subset a data.frame -
i subset data.frame combination of or/and. code using normal r function.
df <- expand.grid(list(a = seq(1, 5), b = seq(1, 5), c = seq(1, 5))) df$value <- seq(1, nrow(df)) df[(df$a == 1 & df$b == 3) | (df$a == 3 & df$b == 2),]
how convert them using filter function in dplyr package? suggestions.
dplyr
solution:
load library:
library(dplyr)
filter status above:
df %>% filter(a == 1 & b == 3 | == 3 & b ==2)
r dplyr
No comments:
Post a Comment