Создайте определенный вывод, используя id и метку времени из другого кадра данных - PullRequest
0 голосов
/ 28 сентября 2019

Имея такой фрейм данных:

dfirst <- structure(list(id = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L), date = c("2008-11-01", "2008-11-01", "2008-11-04", "2008-10-31", 
"2008-10-31", "2008-11-02", "2008-11-02", "2008-11-02", "2008-11-05", 
"2008-11-02", "2008-11-03"), text_sth = c("test", "text_sth", 
"text here", "another text", "other", "another one", "test", 
"text_sth", "text here", "another text", "other")), class = "data.frame", row.names = c(NA, 
-11L))

И второй фрейм данных:

dsecond <- structure(list(id = c(1L, 1L, 1L), name = c("Google", "Yahoo", 
"Amazon"), date = c("2008-11-01", "2008-11-01", "2008-11-04")), class = "data.frame", row.names = c(NA, 
-3L))

Как создать выход, который будет содержать предыдущую и последующую датукак записано во втором фильтре данных в кадре данных 1 данные

id       date     text_sth   name label
1 2008-10-31 another text Google   pre
1 2008-10-31        other Google   pre
1 2008-11-02  another one Google after
1 2008-11-02         test Google after
1 2008-11-02     text_sth Google after
1 2008-11-02 another text Google after
1 2008-10-31 another text  Yahoo   pre
1 2008-10-31        other  Yahoo   pre
1 2008-11-02  another one  Yahoo after
1 2008-11-02         test  Yahoo after
1 2008-11-02     text_sth  Yahoo after
1 2008-11-02 another text  Yahoo after
1 2008-11-03        other Amazon   pre
1 2008-11-05    text here Amazon after
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...