One row per station and day of the window: pigs, visits, unidentified visits, occupation time, feed intake and body weight.

monitor_stations(
  data,
  days = 7,
  end_date = NULL,
  iqr_k = 1.5,
  station = NULL,
  verbose = 1
)

Arguments

data

Station data: a folder or files of NEDAP or FIRE exports (read with read_station()), a raw export already in R such as tidypptsda::nedap, or the result of read_station() or prep_visits().

days

Number of days in the window, ending on end_date. Default 7.

end_date

Last day of the window (a Date or "YYYY-MM-DD"). Default NULL: the last day in the data, or yesterday when the last day is today (an export taken during the day is incomplete).

iqr_k

Body weights of a pig on a day outside the Tukey fences (quartiles -/+ iqr_k times the interquartile range) are outliers. Default 1.5.

station

"nedap", "fire" or NULL (detect), passed to read_station() and prep_visits().

verbose

0 (silent), 1 (summary, default) or 2 (details).

Value

A data.table with one row per station (location) and date, also for days without visits:

  • n_pigs: pigs with at least one identified visit;

  • n_visits: all visits; n_unidentified: visits without a transponder read; pct_unidentified: their percentage;

  • occupation_h: total time the station was occupied, hours;

  • feed_kg: feed intake of all visits, kg; feed_per_pig_kg: feed intake of the identified visits divided by n_pigs;

  • weight_kg: mean over the pigs of their daily median body weight, outliers excluded;

  • pct_weight_outlier: percentage of the recorded body weights that are outliers within the pig and day (see iqr_k).

Counts are 0 and the other columns NA on days without visits.

See also

run_monitor() for all tables at once.

Examples

st <- monitor_stations(tidypptsda::nedap, days = 7, verbose = 0)
st
#>     location       date n_pigs n_visits n_unidentified pct_unidentified
#>       <char>     <Date>  <int>    <int>          <int>            <num>
#>  1:      101 2024-05-19     13      192              2              1.0
#>  2:      101 2024-05-20     13      201              4              2.0
#>  3:      101 2024-05-21     13      228              2              0.9
#>  4:      101 2024-05-22     13      214              3              1.4
#>  5:      101 2024-05-23     13      234              1              0.4
#>  6:      101 2024-05-24     13      154              1              0.6
#>  7:      101 2024-05-25     13      204              4              2.0
#>  8:      102 2024-05-19     15      163              0              0.0
#>  9:      102 2024-05-20     15      167              2              1.2
#> 10:      102 2024-05-21     15      216              2              0.9
#> 11:      102 2024-05-22     15      238              2              0.8
#> 12:      102 2024-05-23     15      158              9              5.7
#> 13:      102 2024-05-24     15      118              3              2.5
#> 14:      102 2024-05-25     15      162              2              1.2
#>     occupation_h feed_kg feed_per_pig_kg weight_kg pct_weight_outlier
#>            <num>   <num>           <num>     <num>              <num>
#>  1:        13.88  50.923           3.903    126.83                3.7
#>  2:        13.38  49.585           3.786    128.02                6.6
#>  3:        12.54  46.784           3.576    128.81                7.1
#>  4:        12.63  44.780           3.429    130.49                6.2
#>  5:        13.22  47.120           3.624    131.21                9.0
#>  6:        12.66  44.424           3.415    132.80                7.2
#>  7:        12.30  42.030           3.226    133.57               10.5
#>  8:        15.26  58.752           3.917    123.13                6.1
#>  9:        15.71  56.385           3.757    124.28                8.5
#> 10:        13.39  47.664           3.176    124.70                7.9
#> 11:        15.24  53.857           3.589    125.29                6.8
#> 12:        12.39  50.520           3.361    125.58                6.7
#> 13:        15.15  55.163           3.675    128.28                8.7
#> 14:        11.77  42.784           2.851    129.64               10.0
# Stations in rows, days in columns
wide_table(st, "feed_kg")
#> Key: <location>
#>    location  05-19  05-20  05-21  05-22 05-23  05-24  05-25   total
#>      <char>  <num>  <num>  <num>  <num> <num>  <num>  <num>   <num>
#> 1:      101 50.923 49.585 46.784 44.780 47.12 44.424 42.030 325.646
#> 2:      102 58.752 56.385 47.664 53.857 50.52 55.163 42.784 365.125
st <- monitor_stations(tidypptsda::nedap, days = 7, verbose = 0)
st
#>     location       date n_pigs n_visits n_unidentified pct_unidentified
#>       <char>     <Date>  <int>    <int>          <int>            <num>
#>  1:      101 2024-05-19     13      192              2              1.0
#>  2:      101 2024-05-20     13      201              4              2.0
#>  3:      101 2024-05-21     13      228              2              0.9
#>  4:      101 2024-05-22     13      214              3              1.4
#>  5:      101 2024-05-23     13      234              1              0.4
#>  6:      101 2024-05-24     13      154              1              0.6
#>  7:      101 2024-05-25     13      204              4              2.0
#>  8:      102 2024-05-19     15      163              0              0.0
#>  9:      102 2024-05-20     15      167              2              1.2
#> 10:      102 2024-05-21     15      216              2              0.9
#> 11:      102 2024-05-22     15      238              2              0.8
#> 12:      102 2024-05-23     15      158              9              5.7
#> 13:      102 2024-05-24     15      118              3              2.5
#> 14:      102 2024-05-25     15      162              2              1.2
#>     occupation_h feed_kg feed_per_pig_kg weight_kg pct_weight_outlier
#>            <num>   <num>           <num>     <num>              <num>
#>  1:        13.88  50.923           3.903    126.83                3.7
#>  2:        13.38  49.585           3.786    128.02                6.6
#>  3:        12.54  46.784           3.576    128.81                7.1
#>  4:        12.63  44.780           3.429    130.49                6.2
#>  5:        13.22  47.120           3.624    131.21                9.0
#>  6:        12.66  44.424           3.415    132.80                7.2
#>  7:        12.30  42.030           3.226    133.57               10.5
#>  8:        15.26  58.752           3.917    123.13                6.1
#>  9:        15.71  56.385           3.757    124.28                8.5
#> 10:        13.39  47.664           3.176    124.70                7.9
#> 11:        15.24  53.857           3.589    125.29                6.8
#> 12:        12.39  50.520           3.361    125.58                6.7
#> 13:        15.15  55.163           3.675    128.28                8.7
#> 14:        11.77  42.784           2.851    129.64               10.0
wide_table(st, "feed_kg")
#> Key: <location>
#>    location  05-19  05-20  05-21  05-22 05-23  05-24  05-25   total
#>      <char>  <num>  <num>  <num>  <num> <num>  <num>  <num>   <num>
#> 1:      101 50.923 49.585 46.784 44.780 47.12 44.424 42.030 325.646
#> 2:      102 58.752 56.385 47.664 53.857 50.52 55.163 42.784 365.125