Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Demo1 <- c(8,9,10,11)
- Demo2 <- c(13,14,15,16)
- Condition <- c('A', 'A', 'B', 'B')
- Var1 <- c(13,76,105,64)
- Var2 <- c(12,101,23,23)
- Var3 <- c(5,5,5,5)
- df <- as.data.frame(cbind(Demo1, Demo2, Condition, Var1, Var2, Var3), stringsAsFactors = F)
- df[4:6] <- lapply(df[4:6], as.numeric)
- df <- df %>%
- filter(Var1 > 100 | Var2 > 100 | Var3 > 100)
- df %>%
- filter_at(vars(matches("^Var")), any_vars(.> 100))
- # Demo1 Demo2 Condition Var1 Var2 Var3
- #1 9 14 A 76 101 5
- #2 10 15 B 105 23 5
- df[Reduce(`|`, lapply(df[grepl("^Var", names(df))], `>`, 100)),]
- df[rowSums((df[,grepl("^Var",names(df))] > 100)) >= 1, ]
- # Demo1 Demo2 Condition Var1 Var2 Var3
- # 2 9 14 A 76 101 5
- # 3 10 15 B 105 23 5
Add Comment
Please, Sign In to add comment