R/logbook_temporal_limit_control.R
logbook_temporal_limit_control.Rd
The purpose of the logbook_temporal_limit_control function is to provide a table of data that contains an inconsistency between trip start and end date and the dates of activity (activity date outside the trip ranges, several occurrences of the activity date, ...)
logbook_temporal_limit_control(dataframe1, dataframe2, output)
data.frame expected. Csv or output of the function data_extraction, which must be done before using the logbook_temporal_limit_control () function.
data.frame expected. Csv or output of the function data_extraction, which must be done before using the logbook_temporal_limit_control () function.
character expected.Kind of expected output. You can choose between "message", "report" or "logical".
The function returns a character with output is "message", two data.frame with output is "report" (the first at the trip level and the second at the activity date level), a logical with output is "logical"
The input dataframe must contain all these columns for the function to work :
trip_id
trip_startdate
trip_enddate
route_id
activity_date
trip_id
#Trip 1 is ok,
#Trip 2 has an extra day (2020/01/03),
#Trip 3 has no trip_startdate,
#Trip 4 has no trip_enddate,
#Trip 5 has a missing day (2020/02/02),
#Trip 6 has a double day (2020/02/13)
dataframe1 <- data.frame(trip_id = c("1", "2", "3", "4", "5", "6"),
trip_startdate = as.Date(c("2020/01/01", "2020/01/01", NA, "2020/01/24",
"2020/02/01", "2020/02/13")),
trip_enddate = as.Date(c("2020/01/02", "2020/01/02", "2020/01/24", NA,
"2020/02/03", "2020/02/14")))
dataframe2 <- data.frame(route_id = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
"12"),
activity_date = as.Date(c("2020/01/01", "2020/01/02", "2020/01/01",
"2020/01/02", "2020/01/03", "2020/01/24",
"2020/01/24", "2020/02/01", "2020/02/03",
"2020/02/13", "2020/02/13", "2020/02/14")),
trip_id = c("1", "1", "2", "2", "2", "3", "4", "5", "5", "6", "6", "6"))
logbook_temporal_limit_control(dataframe1, dataframe2, output = "report")
#> [[1]]
#> trip_id logical
#> 1 1 TRUE
#> 2 2 FALSE
#> 3 3 FALSE
#> 4 4 FALSE
#> 5 5 FALSE
#> 6 6 FALSE
#>
#> [[2]]
#> trip_id trip_startdate trip_enddate activity_date inter_activity_date
#> 1 1 2020-01-01 2020-01-02 2020-01-01 TRUE
#> 2 1 2020-01-01 2020-01-02 2020-01-02 TRUE
#> 3 2 2020-01-01 2020-01-02 2020-01-01 TRUE
#> 4 2 2020-01-01 2020-01-02 2020-01-02 TRUE
#> 5 2 2020-01-01 2020-01-02 2020-01-03 FALSE
#> 6 3 <NA> 2020-01-24 2020-01-24 FALSE
#> 7 4 2020-01-24 <NA> 2020-01-24 FALSE
#> 8 5 2020-02-01 2020-02-03 2020-02-01 TRUE
#> 9 5 2020-02-01 2020-02-03 2020-02-03 TRUE
#> 10 6 2020-02-13 2020-02-14 2020-02-13 TRUE
#> 11 6 2020-02-13 2020-02-14 2020-02-14 TRUE
#> exter_activity_date count_freq logical
#> 1 FALSE 1 TRUE
#> 2 FALSE 1 TRUE
#> 3 FALSE 1 TRUE
#> 4 FALSE 1 TRUE
#> 5 TRUE 1 FALSE
#> 6 FALSE 1 FALSE
#> 7 FALSE 1 FALSE
#> 8 FALSE 1 TRUE
#> 9 FALSE 1 TRUE
#> 10 FALSE 2 FALSE
#> 11 FALSE 1 TRUE
#>