filter data by two columns in R

Viewed 42
dt <- tibble( Date = c("20210103", "20210103", "20210103", "20210104", "20210104", "20210104", "20210105", "20210105", "20210106"), 
              file = c("CBDF_1", "CBDF_2", "CBDF_3", "CBDF_4", "CBDF_5", "CBDF_6", "CBDF_7", "CBDF_8", "CBDF_9")

I want find match both (Date & file) from my original data. my code is

new_date <- as.vector(dt$Date)
new_file <- as.vector(dt$file)

filter(data, Date == new_date & file == new_file )

Got output is

Error in `filter()`:
! Problem while computing `..1 = Date == new_date & file == new_file`.
āœ– Input `..1` must be of size 1, not size 399753.

Does anyone have an idea about how to deal with this problem? Many thanks in advance!!

0 Answers
Related