Create consistent mcs_mileage_data based on an existing data.frame (preferred) or on multiple equal length vectors

mcs_mileage_data(
  data = NULL,
  mileage,
  time,
  status = NULL,
  id = NULL,
  .keep_all = FALSE
)

Arguments

data

Either NULL or a data.frame. If data is NULL, mileage, time, status and id must be vectors containing the data. Otherwise mileage, time, status and id can be either column names or column positions.

mileage

Covered distances. Use NA for missing elements.

time

Operating times. Use NA for missing elements.

status

Optional argument. If used, it must contain binary data (0 or 1) indicating whether a unit is a right censored observation (= 0) or a failure (= 1).

If status is provided, class wt_reliability_data is assigned to the output of mcs_mileage, which enables the direct application of estimate_cdf on distances.

id

Identification of every unit.

.keep_all

If TRUE keep remaining variables in data.

Value

A tibble with class wt_mcs_mileage_data that is formed for the downstream Monte Carlo method mcs_mileage. It contains the following columns (if .keep_all = FALSE):

  • mileage : Input mileages.

  • time : Input operating times.

  • status (optional) :

    • If is.null(status) column status does not exist.

    • If status is provided the column contains the entered binary data (0 or 1).

  • id : Identification for every unit.

If .keep_all = TRUE, the remaining columns of data are also preserved. The attribute mcs_characteristic is set to "mileage".

See also

dist_mileage for the determination of a parametric annual mileage distribution and mcs_mileage for the Monte Carlo method with respect to unknown distances.

Examples

# Example 1 -  Based on an existing data.frame/tibble and column names:
mcs_tbl <- mcs_mileage_data(
  data = field_data,
  mileage = mileage,
  time = dis,
  status = status
)

# Example 2 - Based on an existing data.frame/tibble and column positions:
mcs_tbl_2 <- mcs_mileage_data(
  data = field_data,
  mileage = 3,
  time = 2,
  id = 1
)

# Example 3 - Keep all variables of the tibble/data.frame entered to argument data:
mcs_tbl_3 <- mcs_mileage_data(
  data = field_data,
  mileage = mileage,
  time = dis,
  status = status,
  id = vin,
  .keep_all = TRUE
)

# Example 4 - Based on vectors:
mcs_tbl_4 <- mcs_mileage_data(
  mileage = field_data$mileage,
  time = field_data$dis,
  status = field_data$status,
  id = field_data$vin
)