get_stock_unit
returns the nearest stock unit equivalent for the given animal and year.
The function uses the stock_units data frame to find the nearest year and corresponding stock unit equivalent. The stock_units data frame contains the stock unit equivalents for different animals for the years 1980, 1985, 2000, and 2017. This can be updated as needed, or held constant.
Follows the methods of Snelder et al (2021).
References
Snelder TH, Fraser C, Larned ST, Monaghan R, De Malmanche S, Whitehead AL. Attribution of river water-quality trends to agricultural land use and climate variability in New Zealand. Marine and Freshwater Research. 2021;73(1):1-19. doi:10.1071/mf21086
Examples
get_stock_unit("Sheep", 1990)
#> [1] 0.95
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
test_df <- tibble(
year = rep(c(1970, 1985, 1990, 2005), each = 3),
animal = rep(c("Sheep", "Beef cattle", "Dairy cattle"), times = 4),
count = c(3000, 5000, 7000, 8000, 10000, 6000, 7000, 9000, 11000, 5000, 6000, 7000)
)
test_df |>
rowwise() |>
mutate(stock_unit_equivalent = count * get_stock_unit(animal, year)) |>
ungroup()
#> # A tibble: 12 × 4
#> year animal count stock_unit_equivalent
#> <dbl> <chr> <dbl> <dbl>
#> 1 1970 Sheep 3000 2850
#> 2 1970 Beef cattle 5000 25000
#> 3 1970 Dairy cattle 7000 35000
#> 4 1985 Sheep 8000 7600
#> 5 1985 Beef cattle 10000 53000
#> 6 1985 Dairy cattle 6000 33000
#> 7 1990 Sheep 7000 6650
#> 8 1990 Beef cattle 9000 47700
#> 9 1990 Dairy cattle 11000 60500
#> 10 2005 Sheep 5000 5750
#> 11 2005 Beef cattle 6000 36000
#> 12 2005 Dairy cattle 7000 47600