[Solved] dplyr selecting observations with filter [duplicate]


You could use paste to create the full name and filter to subset on that new variable

library(dplyr)

filter(d,paste(NAME,SURNAME) %in% c("Giovanni Bianchi","Luca Rossi"))

      NAME SURNAME COLOR
1 Giovanni Bianchi   Red
2 Giovanni Bianchi  Blue
3     Luca   Rossi  Blue
4     Luca   Rossi   Red

Data

d <- read.table(text="
NAME          SURNAME   COLOR
Giovanni      Rossi     Red 
Giovanni      Bianchi   Red 
Giovanni      Bianchi   Blue 
Luca          Rossi     Blue
Luca          Rossi     Red
Giovanni      Rossi     Red ",head=TRUE,stringsAsFactors=FALSE)    

0

solved dplyr selecting observations with filter [duplicate]