Skip to contents

Processes and calculates daily and weekly averages of 'GreenFeed' data. Handles data filtering, aggregation, and summarization to facilitate further analysis.

Arguments

data

a data frame with daily or finalized 'GreenFeed' data

start_date

a character string representing the start date of the study (format: "mm/dd/yyyy")

end_date

a character string representing the end date of the study (format: "mm/dd/yyyy")

param1

an integer representing the number of records per day to be consider for analysis

param2

an integer representing the number of days with records per week to be consider for analysis

min_time

an integer representing the minimum number of minutes for a records to be consider for analysis. By default min_time is 2

Value

A list of two data frames:

daily_data

data frame with daily processed 'GreenFeed' data

weekly_data

data frame with weekly processed 'GreenFeed' data

Examples

file <- system.file("extdata", "StudyName_GFdata.csv", package = "greenfeedr")
datafile <- readr::read_csv(file)
#> Rows: 256 Columns: 21
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr   (6): AnimalName, RFID, StartTime, EndTime, InterruptingTags, RunTime
#> dbl  (13): FeederID, CO2GramsPerDay, CH4GramsPerDay, O2GramsPerDay, H2GramsP...
#> lgl   (1): WasInterrupted
#> time  (1): GoodDataDuration
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.

gf_data <- process_gfdata(
  data = datafile,
  start_date = "2024-05-13",
  end_date = "2024-05-25",
  param1 = 2,
  param2 = 3,
  min_time = 2
)
#> Using param1 = 2 , param2 = 3 , min_time = 2
#> CH4: 387.24 +- 67.37
#> CH4 CV = 17.4%
#> CO2: 11198.47 +- 1427.23
#> CO2 CV = 12.7%
#> O2: 7578.41 +- 917.46
#> O2 CV = 12.1%
#> H2: NaN +- NA
#> H2 CV = NA%
head(gf_data)
#> $daily_data
#> # A tibble: 61 × 9
#>    RFID     week day                     n minutes CH4GramsPerDay CO2GramsPerDay
#>    <chr>   <dbl> <dttm>              <int>   <dbl>          <dbl>          <dbl>
#>  1 840003…     1 2024-05-13 00:00:00     7   25.9            453.         11995.
#>  2 840003…     1 2024-05-14 00:00:00     5   14.5            245.          7704.
#>  3 840003…     1 2024-05-15 00:00:00     5   17.3            428.         11108.
#>  4 840003…     1 2024-05-19 00:00:00     2    5.65           403.         13532.
#>  5 840003…     1 2024-05-14 00:00:00     3    8.45           263.          8321.
#>  6 840003…     1 2024-05-15 00:00:00     4   10.8            432.         11721.
#>  7 840003…     1 2024-05-16 00:00:00     2    4.73           427.         13417.
#>  8 840003…     1 2024-05-16 00:00:00     4   15.5            504.         12996.
#>  9 840003…     1 2024-05-17 00:00:00     3   11.0            374.         11524.
#> 10 840003…     1 2024-05-18 00:00:00     2    6.66           411.         11474.
#> # ℹ 51 more rows
#> # ℹ 2 more variables: O2GramsPerDay <dbl>, H2GramsPerDay <dbl>
#> 
#> $weekly_data
#> # A tibble: 10 × 9
#>    RFID             week nDays nRecords TotalMin CH4GramsPerDay CO2GramsPerDay
#>    <chr>           <dbl> <int>    <int>    <dbl>          <dbl>          <dbl>
#>  1 840003234513955     1     4       19     63.4           394.         10907.
#>  2 840003234513977     1     3        9     24.0           372.         10859.
#>  3 840003250681234     1     4       11     42.1           466.         12546.
#>  4 840003250681655     1     5       19     51.3           340.         10969.
#>  5 840003250681661     1     3       14     59.3           354.         10934.
#>  6 840003250681664     1     5       17     62.6           506.         13682.
#>  7 840003250681689     1     6       15     59.7           407.         11378.
#>  8 840003250681711     1     4       10     29.7           430.         12428.
#>  9 840003250681766     1     5       15     53.8           312.          9210.
#> 10 840003250681788     1     6       30    101.            293.          9070.
#> # ℹ 2 more variables: O2GramsPerDay <dbl>, H2GramsPerDay <dbl>
#>