我想根据“ check_in”和“ check_out”之前1天之间的日期顺序添加新列“ date_seq”。我使用purrrr:map2(check_in,check_out,〜seq(check_in,check_out-1,1))作为屏幕快照的附件。我尝试了2种方法,但是使用管道(第2行)的方法无法正常工作。可能是什么原因?
尝试使用:
library(dplyr)
test_df %>%
mutate(date = purrr::map2(check_in, check_out, ~ seq(.x, .y - 1, 'day'))) %>%
tidyr::unnest(date) %>%
select(-check_in, check_out)