I want to filter a data frame to include only rows that have matching values in certain columns.
My data:
df <- data.frame("Date" = ymd(c("2005-01-01", "2005-01-02", "2005-01-02", "2005-01-01", "2005-01-01")),
"Person" = c("John", "John", "John", "Maria", "Maria"),
"Job" = c("OR", "ER", "Heart", "Liver", "CV"),
"Type" = c("Day", "Night", "Night", "Day", "Night"))
I want to create a smaller data frame that includes rows that match on the date, the person, and the type.
The data frame I want to see is this:
df1 <- data.frame("Date" = ymd(c("2005-01-02", "2005-01-02")),
"Person" = c("John", "John"),
"Job" = c("ER", "Heart"),
"Type" = c("Night", "Night"))