One row per house and day: the stations of a house are grouped by the first house_width characters of their ID.

monitor_houses(
  data,
  days = 7,
  end_date = NULL,
  house_width = 1,
  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).

house_width

Number of leading characters of the station ID that name its house, e.g. 1 for station "203" in house "2". Default 1.

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 house and date: n_stations (stations of the house in the data), n_pigs, n_visits, feed_kg, feed_per_pig_kg (as in monitor_stations()) and weight_kg (mean over the pigs of their daily median body weight).

See also

Examples

monitor_houses(tidypptsda::nedap, days = 5, verbose = 0)
#>     house       date n_stations n_pigs n_visits feed_kg feed_per_pig_kg
#>    <char>     <Date>      <int>  <int>    <int>   <num>           <num>
#> 1:      1 2024-05-21          2     28      444  94.448           3.362
#> 2:      1 2024-05-22          2     28      452  98.637           3.515
#> 3:      1 2024-05-23          2     28      392  97.640           3.483
#> 4:      1 2024-05-24          2     28      272  99.587           3.554
#> 5:      1 2024-05-25          2     28      366  84.814           3.025
#>    weight_kg
#>        <num>
#> 1:    126.50
#> 2:    127.62
#> 3:    128.08
#> 4:    130.36
#> 5:    131.39
# Every station its own house
monitor_houses(tidypptsda::nedap, days = 5, house_width = 3, verbose = 0)
#>      house       date n_stations n_pigs n_visits feed_kg feed_per_pig_kg
#>     <char>     <Date>      <int>  <int>    <int>   <num>           <num>
#>  1:    101 2024-05-21          1     13      228  46.784           3.576
#>  2:    101 2024-05-22          1     13      214  44.780           3.429
#>  3:    101 2024-05-23          1     13      234  47.120           3.624
#>  4:    101 2024-05-24          1     13      154  44.424           3.415
#>  5:    101 2024-05-25          1     13      204  42.030           3.226
#>  6:    102 2024-05-21          1     15      216  47.664           3.176
#>  7:    102 2024-05-22          1     15      238  53.857           3.589
#>  8:    102 2024-05-23          1     15      158  50.520           3.361
#>  9:    102 2024-05-24          1     15      118  55.163           3.675
#> 10:    102 2024-05-25          1     15      162  42.784           2.851
#>     weight_kg
#>         <num>
#>  1:    128.67
#>  2:    130.43
#>  3:    131.04
#>  4:    132.76
#>  5:    133.44
#>  6:    124.61
#>  7:    125.17
#>  8:    125.53
#>  9:    128.28
#> 10:    129.61
monitor_houses(tidypptsda::nedap, days = 5, verbose = 0)
#>     house       date n_stations n_pigs n_visits feed_kg feed_per_pig_kg
#>    <char>     <Date>      <int>  <int>    <int>   <num>           <num>
#> 1:      1 2024-05-21          2     28      444  94.448           3.362
#> 2:      1 2024-05-22          2     28      452  98.637           3.515
#> 3:      1 2024-05-23          2     28      392  97.640           3.483
#> 4:      1 2024-05-24          2     28      272  99.587           3.554
#> 5:      1 2024-05-25          2     28      366  84.814           3.025
#>    weight_kg
#>        <num>
#> 1:    126.50
#> 2:    127.62
#> 3:    128.08
#> 4:    130.36
#> 5:    131.39