This function is used to produce error result.

resolve_data_with_error(data_with_error, initial_res_status_data,
  error_message = "", include_error_columns = FALSE,
  window_size = 487)

Arguments

data_with_error

The personal crossing data for RBC process with error.

initial_res_status_data

the initial residence status data.

error_message

The error message.

include_error_columns

Optional, if it is TRUE, the returned result of error_data will contain two extra columns error_code and error_message.

window_size

The maximum length of the scanning period. Can be an integer giving the number of days, the result of a call to function difftime, or an object of class Duration.

Value

A dataframe type of object contains journeys with error.

Examples

## to suppresse log messages to the console migrbc::initialize_logger(log_level = 1)
#> logger 'migrbc' has log_level=1 and writes to the console
j1 <- c(journeyId = 1, personId = 1, is_arrival = 1, date_crossing = '2017-01-01', journey_sequence = 1, journeyId_prev = NA) j2 <- c(journeyId = 2, personId = 1, is_arrival = 1, date_crossing = '2018-01-06', journey_sequence = 2, journeyId_prev = 1) j3 <- c(journeyId = 3, personId = 1, is_arrival = 1, date_crossing = '2018-01-16', journey_sequence = 3, journeyId_prev = 2) j4 <- c(journeyId = 4, personId = 2, is_arrival = 0, date_crossing = '2017-01-01', journey_sequence = 1, journeyId_prev = NA) j5 <- c(journeyId = 5, personId = 2, is_arrival = 0, date_crossing = '2018-01-06', journey_sequence = 2, journeyId_prev = 4) j6 <- c(journeyId = 6, personId = 2, is_arrival = 0, date_crossing = '2018-01-16', journey_sequence = 3, journeyId_prev = 5) person_data <- as.data.frame(rbind(j1, j2, j3, j4, j5, j6), stringsAsFactors = FALSE) i1 <- c(personId = 1, res_status_initial = 1, date_finalised = '2017-01-01') ini_data <- as.data.frame(t(i1), stringsAsFactors = FALSE) person_data$journeyId <- as.numeric(person_data$journeyId) person_data$personId <- as.numeric(person_data$personId) person_data$is_arrival <- as.numeric(person_data$is_arrival) person_data$journey_sequence <- as.numeric(person_data$journey_sequence) person_data$journeyId_prev <- as.numeric(person_data$journeyId_prev) ini_data$personId <- as.numeric(ini_data$personId) ini_data$res_status_initial <- as.numeric(ini_data$res_status_initial) ini_data$date_finalised <- as.character(ini_data$date_finalised) res <- migrbc::resolve_data_with_error(person_data, initial_res_status_data = ini_data, error_message = 'custom error', include_error_columns = TRUE) head(res)
#> journeyId journeyId_prev personId date_crossing journey_sequence #> 1 1 NA 1 2017-01-01 1 #> 2 2 1 1 2018-01-06 2 #> 3 3 2 1 2018-01-16 3 #> 4 4 NA 2 2017-01-01 1 #> 5 5 4 2 2018-01-06 2 #> 6 6 5 2 2018-01-16 3 #> days_to_next_crossing is_arrival res_status_before res_status_after #> 1 370 1 1 1 #> 2 10 1 1 1 #> 3 487 1 1 1 #> 4 370 0 1 1 #> 5 10 0 1 1 #> 6 487 0 1 1 #> is_long_term_mig date_finalised_res_before date_finalised_res_after #> 1 0 2017-01-01 2017-01-01 #> 2 0 2018-01-06 2018-01-06 #> 3 0 2018-01-16 2018-01-16 #> 4 0 2017-01-01 2017-01-01 #> 5 0 2018-01-06 2018-01-06 #> 6 0 2018-01-16 2018-01-16 #> date_finalised_LTM error_code error_message #> 1 2017-01-01 99 custom error #> 2 2018-01-06 99 custom error #> 3 2018-01-16 99 custom error #> 4 2017-01-01 99 custom error #> 5 2018-01-06 99 custom error #> 6 2018-01-16 99 custom error