How to determine number of service dates and days between two snapshots in a dataframe?
I’m trying to take data from a nearly-weekly snapshot [some weeks are missing due to holidays, server issues, etc.] and determine the number of service dates between one snapshot and the next. I have a calendar of all dates of service to reference, but I have no idea where to begin with finding the number of dates in the calendar between one data snapshot and the next. I also need to determine the number of days the service actually ran [some only run Monday-Wednesday, for example] so I can calculate the total mileage each route drove during the period of the study.
Create variable Date
I want to create a variable Date from 3 variables in my dataframe : data <- data %>% mutate(Z49= if_else( !is.na(Z49j) & !is.na(Z49m) & !is.na(Z49a) & Z49j != “” & Z49m != “” & Z49a != “”, dmy(paste0(Z49j, “-“, Z49m, “-“, Z49a)), NA_Date_ )) It return this error : Warning message: All formats failed to […]
Why is the lubridate package returning invalid time zone error?
I recently updated to R version 4.4 and lubridate version 1.9.1 and started getting this error below when I try to add a period of time to a posixct variable.
Convert numeric data to times and back again
I have a large dataset with a ‘time’ column containing the lubridate ‘Period’ time format, ie ‘xH yM zS, for example 3H 30M 0S. All of the data is in fractions of an hour, the smallest fraction is 15min, most are either on the hour or half past. Is there a way to convert these to simple numerals, so 3H 30M 0S becomes 3.5.