I am trying to convert a duration between 2 dates in days with lubridate package in R and getting some error messages. I tried the following codes:
tbls_data_new1<- tbls_data_new %>% mutate(days = interval(end,start),
days = as.period(days) )
The codes above work and I am getting the interval in year-month-day-time.... I want to convert this in days and tried the following:
I am getting results like that:
-358084800d 0H 0M 0S
Here is the data head from the portion that works. Thanks for the help
structure(list(name_birtha_death = c("Toussaint Louverture(1743-1803)",
"Jean-Jacques Dessalines(1758-1806)", "Henri Christophe(1767-1820)",
"Alexandre Pétion(1770-1818)", "Jean-Pierre Boyer(1776-1850)",
"Jean-Pierre Boyer(1776-1850)"), start = structure(c(-65378,
-60631, -59611, -59611, -55429, -54496), class = "Date"), end = structure(c(-61236,
-60366, -57988, -55430, -54496, -46343), class = "Date"), days = new("Period",
.Data = c(0, 0, 0, 0, 0, 0), year = c(-11, 0, -4, -11, -2,
-22, -1, 0, 0, 0, -2, -8, 0, -2, -4, -1, -3, 0, -8, 0, 0,
0, -6, -6, 0, -5, -2, 0, 0, 0, 0, 0, 0, -6, -8, 0, -10, -4,
0, -3, 0, -6, 0, 0, 0, 0, -13, -14, -2, 0, 0, -1, 0, 0, 0,
-1, -1, -5, -3, -2, -5, -5, -4, 0, -4), month = c(-4, -8,
-5, -5, -6, -3, 0, -11, -11, -11, -5, -1, -1, -7, -4, -10,
-2, -2, -10, -2, -10, -1, -5, -1, -6, -11, -7, -11, -8, -8,
-8, -3, -5, -9, 0, -6, -5, -7, -7, -8, -6, 0, -1, -1, 0,
-4, -5, -9, 0, -4, -2, -5, -10, -7, -8, -3, -3, 0, 0, -2,
0, 0, -8, -11, -5), day = c(-5, -21, -11, -12, -19, -26,
-29, -12, -8, -4, -24, -22, -13, -23, -18, -1, -24, -7, -8,
-6, -7, -25, -7, -12, -22, -12, -28, -24, -25, -15, -21,
-15, -3, -3, 0, -3, -27, -27, -5, -25, -27, -6, -22, -23,
-20, -8, -30, -16, 0, -13, -27, -23, -25, -22, -11, -27,
-26, 0, -22, -14, 0, 0, -24, -22, 0), hour = c(0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0), minute = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -6L), .internal.selfref = <pointer: 0x000001fea26b1ef0>)
I would appreciate any help.