I have 2 df that have a date of birth variable and I want to select the identical values.
> head(base$fec_nac)
[1] "1981-06-22" "1974-06-12" "1981-08-20" "1954-07-28" "1982-09-27" "1935-01-02"
> head(base2$fechanacimiento)
[1] "1983-07-13" "1964-06-01" "1950-12-29" "1951-07-03" "1958-09-04" "1961-05-29"
intersect(base$fec_nac, base2$fechanacimiento) %>%
length()
251
but when I go to one of these bases to select the values, it only selects 9 instead of 251.
> base %>%
+ filter(fec_nac %in% intersect(base$fec_nac, base2$fechanacimiento)) %>%
+ nrow
[1] 6
> base2 %>%
+ filter(fechanacimiento %in% intersect(base$fec_nac, base2$fechanacimiento)) %>%
+ nrow
[1] 186
the strange thing is that intersect() does not return dates but numbers.
> head(intersect(base$fec_nac, base2$fechanacimiento))
[1] 4190 1623 4249 -5636 4652 -12783