ADG get from pig performance test station csv data

adg_get(
  data,
  my_break = NULL,
  range_offset = 0.5,
  threshold = 1,
  save_path = NULL
)

Arguments

data

A data frame or data table containing the nedap or fire pig performance test data to be processed. Columns must include 'visit_time', 'location', 'responder', 'feed_intake'.

my_break

Optional, a numeric vector of length 2, indicates target weight range for calculating ADG, default NULL. If not NULL, ADG will be calculated within this range.

range_offset

Optional, a numeric value, default 0.5. Used to extend the target weight range specified in my_break to avoid border effect. For example, if my_break is c(60,90) and range_offset is 0.5, the actual range for analysis will be 57.5~92.5.

threshold

Optional, a numeric value, default 1, used as the threshold to identify outliers in RANSAC regression, usually 0~2.

save_path

Optional, a character string specifying where to save the generated growth curve images. If not NULL, images will be saved to this path.

Value

A list containing:

  • adg_info: A data.table containing ADG statistics

  • adg_data: A data.table containing processed sample data

Examples

nedap_csv_data <- mintyr::nedap
adg_results <- adg_get(data = nedap_csv_data)
#> • There are no duplicate responders in different locations.
#> • The removing of weight < 15kg will not delete responder.
#> • Removing records of missing will delete responders: 1
#> • Deleted responders: 
#>  c("15964")
#> • Running RANSAC Robust Regression:
#> • RANSAC Robust Regression succeeded!
#> • The outliers detected by Robust model will not delete responder.
#> • All responders' begin_test_weight are less than or equal to 60kg.
#> • Removing end_test_weight <85kg records will delete responders: 1
#> • Deleted responders: 
#>  c("15967")
#> • Running Simple Linear Regression
#> • Calculate ADG using Simple Linear Regression succeeded!
head(adg_results$adg_info)
#> Key: <responder>
#>    responder location start_date_origin min_weight_origin end_date_origin
#>       <char>   <char>            <Date>             <num>          <Date>
#> 1:     13913      101        2024-02-19          21866.22      2024-05-25
#> 2:     13918      101        2024-02-19          16529.06      2024-05-25
#> 3:     13935      102        2024-02-19          21414.80      2024-05-25
#> 4:     13954      101        2024-02-20          30876.25      2024-05-25
#> 5:     13996      101        2024-02-19          22753.31      2024-05-25
#> 6:     14260      102        2024-02-19          27757.93      2024-05-25
#>    max_weight_origin r_squared  lm_slope
#>                <num>     <num>     <num>
#> 1:          132895.4 0.9914949 1180.5834
#> 2:          121102.8 0.9917870 1089.6744
#> 3:          138871.4 0.9976035 1233.5471
#> 4:          118602.7 0.9781564  941.2985
#> 5:          142956.6 0.9957625 1281.2277
#> 6:          142547.7 0.9962627 1221.0429