Skip to content

Commit 59156c2

Browse files
committed
Merge remote-tracking branch 'origin/staging'
2 parents 5f14888 + 24921e2 commit 59156c2

17 files changed

+9123
-477
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ Imports:
3535
utils,
3636
rlang,
3737
stringr,
38-
ggplot2
38+
ggplot2,
39+
openxlsx
3940
Suggests:
4041
knitr,
4142
rmarkdown,

R/compare_scenario.R

Lines changed: 340 additions & 258 deletions
Large diffs are not rendered by default.

R/feed_quality.R

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ feed_quality <- function(para) {
3939

4040
livestock_type_selected <- livestock_df[livestock_df$livetype_code == livestock, ]
4141

42-
4342
for (season in 1:nrow(seasons)) {
4443

4544
feed_production <- unnest(para[["feed_items"]], cols = c(feed_type_name))
@@ -49,9 +48,7 @@ feed_quality <- function(para) {
4948
feed_allocation <- list()
5049

5150
for (i in 1:length(feed_types)) {
52-
53-
feed_selected <- feed_production %>% dplyr::filter(feed_type_name %in%
54-
feed_production$feed_type_name[i])
51+
feed_selected <- feed_production %>% dplyr::filter(feed_type_name %in% feed_types[i])
5552

5653
#feed_item <- as.data.frame(feed_selected[["feed_items"]])
5754

@@ -77,7 +74,7 @@ feed_quality <- function(para) {
7774
seasons$season_name[season])
7875

7976
feed_item_selected <- feeding_seasons %>%
80-
dplyr::filter(feed_item_code == feed_selected[["feed_item_code"]])
77+
dplyr::filter(feed_item_code %in% feed_selected[["feed_item_code"]])
8178

8279
livestock_selected <- feed_item_selected[["livestock"]] %>%
8380
as.data.frame() %>%
@@ -135,7 +132,7 @@ feed_quality <- function(para) {
135132
feed_allocation_all[is.na(feed_allocation_all)] <- 0
136133

137134
# Bind and add into the season list
138-
season_allocation[[season]] <- cbind(season_name = rep(feed_item_selected$season_name, times = nrow(feed_allocation_all)),
135+
season_allocation[[season]] <- cbind(season_name = rep(feed_item_selected$season_name[1],times = nrow(feed_allocation_all)),
139136
livestock_category_code = rep(livestock_selected$livetype_code, times = nrow(feed_allocation_all)),
140137
livestock_category_name = rep(livestock_type_selected$livetype_desc, times = nrow(feed_allocation_all)),
141138
feed_allocation_all)
@@ -155,4 +152,6 @@ feed_quality <- function(para) {
155152
# Bind by rows
156153
livestock_feed_allocation <- livestock_allocation %>% bind_rows()
157154

155+
return(livestock_feed_allocation)
156+
158157
}

R/ghg_emission.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ ghg_emission <- function(para, energy_required, ghg_ipcc_data, land_required, ni
9797
#Computing methane enteric emission factor
9898

9999
ef <- ym1%>%
100-
mutate(enteric_methane_emissions = (ge_intake*(ym/100)*no_days)/55.65) #equation 10.21
100+
mutate(enteric_methane_emissions = ((ge_intake/no_days)*(ym/100)*no_days)/55.65) #equation 10.21
101101

102102
############################################################################################################################
103103
#Computing methane emission from manure management T2

R/merge_outputs.R

Lines changed: 103 additions & 116 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)