One row per pig and day, from the first day the pig was seen (or the start of the window) to the last day of the window. A day without any visit is kept with status = "no_visit", so a pig that stopped eating is never missing from the table.

monitor_pigs(
  data,
  days = 7,
  end_date = NULL,
  low_feed_kg = 0.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).

low_feed_kg

A pig that ate less than this on a day (kg) is "low_feed". Default 0.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 pig (responder) and date, for the pigs with at least one identified visit in the window:

  • location: the station where the pig had most visits in the window;

  • n_visits, feed_kg, occupation_min (minutes), weight_kg (median body weight of the day);

  • status: "no_visit", "low_feed" (less than low_feed_kg) or "ok".

See also

run_monitor(), whose pig_summary sums this table up per pig.

Examples

pigs <- monitor_pigs(tidypptsda::fire, days = 7, verbose = 0)
pigs[status != "ok"]
#>    location responder       date n_visits feed_kg occupation_min weight_kg
#>      <char>    <char>     <Date>    <int>   <num>          <num>     <num>
#> 1:      102     35857 2024-02-22        2  -0.012            7.8     118.4
#> 2:      102     35860 2024-02-22        4   0.006            5.6     122.8
#> 3:      102     35861 2024-02-22        4   0.096           12.3     137.2
#> 4:      102     35882 2024-02-22        4   0.300            8.9     131.7
#> 5:      102     35883 2024-02-22        2   0.004            0.5        NA
#>      status
#>      <char>
#> 1: low_feed
#> 2: low_feed
#> 3: low_feed
#> 4: low_feed
#> 5: low_feed
wide_table(pigs, "feed_kg")
#> Key: <location, responder>
#>     location responder 02-16 02-17 02-18 02-19 02-20 02-21  02-22  total
#>       <char>    <char> <num> <num> <num> <num> <num> <num>  <num>  <num>
#>  1:      101     25822 2.850 2.914 3.980 3.227 2.056 3.091  0.801 18.919
#>  2:      101     35853 3.919 3.624 4.488 4.985 4.021 4.539  2.618 28.194
#>  3:      101     35855 5.160 5.118 5.351 4.815 6.138 4.382  2.188 33.152
#>  4:      101     35862 4.274 3.430 3.969 3.046 5.106 4.139  1.304 25.268
#>  5:      101     35865 3.190 3.306 4.682 3.755 4.737 3.125  1.707 24.502
#>  6:      101     35869 4.044 3.981 2.252 3.321 3.644 3.828  2.710 23.780
#>  7:      101     35873 2.386 3.724 3.708 3.439 4.188 4.024  2.015 23.484
#>  8:      101     35875 2.187 3.000 3.496 2.928 3.090 2.833  2.751 20.285
#>  9:      101     35877 3.886 3.010 4.712 4.233 4.360 4.211  1.848 26.260
#> 10:      101     35878 3.891 4.614 4.965 4.860 4.885 4.922  3.560 31.697
#> 11:      101     35885 3.719 4.039 4.177 4.353 4.336 3.850  1.639 26.113
#> 12:      101     35887 1.852 2.235 3.029 2.933 2.859 2.686  1.519 17.113
#> 13:      102     35851 4.076 4.667 4.153 3.424 5.646 4.215  1.733 27.914
#> 14:      102     35857 3.180 4.124 4.765 3.097 3.320 4.641 -0.012 23.115
#> 15:      102     35858 4.600 4.592 6.018 5.047 5.396 5.010  2.460 33.123
#> 16:      102     35860 2.716 3.794 4.889 2.982 6.458 3.987  0.006 24.832
#> 17:      102     35861 4.788 3.361 5.128 4.033 4.361 5.297  0.096 27.064
#> 18:      102     35868 4.821 3.142 4.666 3.861 6.130 3.573  2.083 28.276
#> 19:      102     35874 4.135 3.714 4.062 3.653 2.841 4.962  2.557 25.924
#> 20:      102     35876 3.133 4.844 4.210 4.292 4.300 4.486  3.941 29.206
#> 21:      102     35882 4.245 3.419 3.918 3.518 4.145 4.570  0.300 24.115
#> 22:      102     35883 4.245 2.941 3.602 3.441 4.349 3.530  0.004 22.112
#> 23:      102     35892 2.555 3.799 4.404 5.640 4.531 3.944  1.483 26.356
#> 24:      102     35894 3.970 4.288 2.460 3.951 4.138 4.603  1.335 24.745
#> 25:      102     35897 4.435 4.688 4.404 4.470 6.106 4.283  3.182 31.568
#>     location responder 02-16 02-17 02-18 02-19 02-20 02-21  02-22  total
#>       <char>    <char> <num> <num> <num> <num> <num> <num>  <num>  <num>
pigs <- monitor_pigs(tidypptsda::fire, days = 7, verbose = 0)
pigs[status != "ok"]
#>    location responder       date n_visits feed_kg occupation_min weight_kg
#>      <char>    <char>     <Date>    <int>   <num>          <num>     <num>
#> 1:      102     35857 2024-02-22        2  -0.012            7.8     118.4
#> 2:      102     35860 2024-02-22        4   0.006            5.6     122.8
#> 3:      102     35861 2024-02-22        4   0.096           12.3     137.2
#> 4:      102     35882 2024-02-22        4   0.300            8.9     131.7
#> 5:      102     35883 2024-02-22        2   0.004            0.5        NA
#>      status
#>      <char>
#> 1: low_feed
#> 2: low_feed
#> 3: low_feed
#> 4: low_feed
#> 5: low_feed