Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # generate some example data
- set.seed(1234)
- df <- data.frame(
- col1 = rbinom(100, 1, 0.5),
- col2 = rbinom(100, 1, 0.5),
- col3 = rbinom(100, 1, 0.5),
- col4 = rbinom(100, 1, 0.5),
- col5 = rbinom(100, 1, 0.5),
- col6 = rbinom(100, 1, 0.5))
- # the long, explicit way with base R
- df[df$col2 == 1 & df$col4 == 1 & df$col6 == 1, ]
- # or, equivalently with "subset"
- subset(df, col2 ==1 & col4 == 1 & df$col6 == 1)
Add Comment
Please, Sign In to add comment