Skip to content

Commit

Permalink
removed VoP data for cases with too few crops reported
Browse files Browse the repository at this point in the history
  • Loading branch information
Debbora Leip committed Mar 25, 2024
1 parent 941f22c commit 8609976
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '6155934'
ValidationKey: '6179784'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'mrfactors: MADRaT based package on factor inputs'
version: 0.3.11
date-released: '2024-03-12'
version: 0.3.12
date-released: '2024-03-25'
abstract: This package provides functions for MAgPIE input data on factor inputs to
agricultural production (with a focus on capital and labor).
authors:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: mrfactors
Title: MADRaT based package on factor inputs
Version: 0.3.11
Date: 2024-03-12
Version: 0.3.12
Date: 2024-03-25
Authors@R:
c(person("Debbora", "Leip", , "[email protected]", role = c("aut", "cre")),
person("Edna", "Molina Bacca", role = "aut"))
Expand Down
2 changes: 2 additions & 0 deletions R/calcHourlyLaborCosts.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ calcHourlyLaborCosts <- function(datasource = "USDA_FAO", dataVersionILO = "Aug2
totalLaborCosts <- totalLaborCosts[, , str_to_title(sector)]
} else {
agEmpl <- dimSums(agEmpl, dim = 3)
incl <- totalLaborCosts[, , "Livestock"] * totalLaborCosts[, , "Crops"]
totalLaborCosts <- dimSums(totalLaborCosts, dim = 3)
totalLaborCosts[incl == 0] <- 0
}

# calculate hourly labor costs
Expand Down
8 changes: 6 additions & 2 deletions R/calcLaborCosts.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ calcLaborCosts <- function(datasource = "ILO", dataVersionILO = "Aug23", subsect
# estimate total labor costs as share of VoP
out <- vopAg[, years, ] * shares

# aggregate if subsectors is FALSE
if (isFALSE(subsectors)) out <- dimSums(out, dim = 3)
# aggregate if subsectors is FALSE, but only in cases where both crops and livestock are included
if (isFALSE(subsectors)) {
incl <- out[, , "Livestock"] * out[, , "Crops"]
out <- dimSums(out, dim = 3)
out[incl == 0] <- 0
}

} else if (datasource == "GTAP") {

Expand Down
6 changes: 6 additions & 0 deletions R/calcVoPcrops.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ calcVoPcrops <- function(fillGaps = TRUE) {

vopKcrAggregated[!is.finite(vopKcrAggregated)] <- 0

# we exclude all year-country combinations for which less than 5 crop categories are reported
repValues <- dimSums(vopKcrAggregated > 0, dim = 3)
l5 <- repValues < 5
vopKcrAggregated[l5] <- 0


weight <- NULL
units <- "mio USD05 MER"

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MADRaT based package on factor inputs

R package **mrfactors**, version **0.3.11**
R package **mrfactors**, version **0.3.12**

[![CRAN status](https://www.r-pkg.org/badges/version/mrfactors)](https://cran.r-project.org/package=mrfactors) [![R build status](https://github.com/pik-piam/mrfactors/workflows/check/badge.svg)](https://github.com/pik-piam/mrfactors/actions) [![codecov](https://codecov.io/gh/pik-piam/mrfactors/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrfactors) [![r-universe](https://pik-piam.r-universe.dev/badges/mrfactors)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -38,7 +38,7 @@ In case of questions / problems please contact Debbora Leip <[email protected]

To cite package **mrfactors** in publications use:

Leip D, Molina Bacca E (2024). _mrfactors: MADRaT based package on factor inputs_. R package version 0.3.11, <URL: https://github.com/pik-piam/mrfactors>.
Leip D, Molina Bacca E (2024). _mrfactors: MADRaT based package on factor inputs_. R package version 0.3.12, <URL: https://github.com/pik-piam/mrfactors>.

A BibTeX entry for LaTeX users is

Expand All @@ -47,7 +47,7 @@ A BibTeX entry for LaTeX users is
title = {mrfactors: MADRaT based package on factor inputs},
author = {Debbora Leip and Edna {Molina Bacca}},
year = {2024},
note = {R package version 0.3.11},
note = {R package version 0.3.12},
url = {https://github.com/pik-piam/mrfactors},
}
```

0 comments on commit 8609976

Please sign in to comment.