我有一个数据集,其中设置了录音机以进行录音。技术人员记录了部署录音机的日期和时间。然后技术人员将返回并更换电池和存储卡,其中将记录日期。因此,我有每次安装新存储器的日期,或者我认为是录音开始的日期。我正在努力如何填写“date_of_pickup”列基于知道它们是何时按顺序部署的。基本上我知道每个记录器第二次观察的“date_of_deployment”是我需要插入到“date_of_pickup”中的日期。
data <- structure(list(recorder_id = c("smm03978", "smm03895", "smm03922",
"smm03886", "smm03918", "smm04004", "smm03988", "smm03890", "smm03753",
"smm03976", "smm03988", "smm04004", "smm03918", "smm03922", "smm03886",
"smm03976", "smm03895", "smm03753", "smm04004", "smm03753", "smm03890",
"smm03978", "smm03918", "smm03895", "smm03978", "smm03976", "smm04004",
"smm03988", "smm03922", "smm03886", "smm03753", "smm03890"),
card_id = c("msd-1285\n", "msd-1326", "msd- 0198", "msd-1463",
"msd-1478", "msd-0722", "msd-1365", "msd-0807", "msd-0247",
"msd-1430", "msd-2683", NA, "msd-2687", "msd-0530", "msd-2682",
"msd-2688", "msd-2684", NA, "msd-2826", "msd-2830", "msd-2829",
"msd-2828", "msd-2885", "msd-2881", "msd-2878", "msd-2882",
"msd-2879", "msd-2877", "msd-2884", "msd-2880", "msd-2886",
"msd-2883"), date_of_deployment = c("2022-04-02 13:50:00",
"2022-04-02 14:03:00", "2022-04-02 14:41:00", "2022-04-02 14:58:00",
"2022-04-02 17:34:00", "2022-04-02 18:27:00", "2022-04-02 18:49:00",
"2022-04-03 15:19:00", "2022-04-03 15:32:00", "2022-04-03 16:06:00",
"2022-06-24 01:42:00", "2022-06-23 15:44:00", "2022-06-23 16:15:00",
"2022-06-23 17:17:00", "2022-06-23 17:32:00", "2022-06-23 18:00:00",
"2022-06-23 18:26:00", "2022-06-29 01:25:00", "2022-07-14 13:46:00",
"2022-07-15 17:30:00", "2022-07-15 17:48:00", "2022-07-15 18:27:00",
"2022-09-10 15:00:00", "2022-09-10 15:27:00", "2022-09-10 15:37:00",
"2022-09-10 16:03:00", "2022-09-10 16:38:00", "2022-09-10 16:45:00",
"2022-09-10 18:29:00", "2022-09-10 18:38:00", "2022-09-10 19:04:00",
"2022-09-10 19:14:00"), date_of_pickup = c("", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "")), row.names = c(NA,
-32L), class = c("tbl_df", "tbl", "data.frame"))
1条答案
按热度按时间yi0zb3m41#
编辑:也许你想要
mutate(date_of_pickup = lead(date_of_deployment))
而不是mutate(date_of_pickup = nth(date_of_deployment, 2))
?这将导致以下输出: