Skip to content

Commit da199b2

Browse files
committed
Adding keywords internal
1 parent a021a4c commit da199b2

24 files changed

Lines changed: 78 additions & 30 deletions

R/GRAFS_N_Inputs_git.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ create_n_inputs_grafs_spain <- function() {
4848

4949
# N Inputs --------------------------------------------------------------------
5050
# load data -------------------------------------------------------------------
51+
# @keywords internal
5152
.load_inputs_n_inputs <- function() {
5253
result <-
5354
list(
@@ -65,6 +66,7 @@ create_n_inputs_grafs_spain <- function() {
6566
}
6667

6768
# Assign some special items to Boxes ------------------------------------------
69+
# @keywords internal
6870
.assign_items <- function() {
6971
list(
7072
semi_natural_agroecosystems = c(
@@ -80,6 +82,7 @@ create_n_inputs_grafs_spain <- function() {
8082
}
8183

8284
# Calculate n Inputs ----------------------------------------------------------
85+
# @keywords internal
8386
.calculate_n_inputs <- function(n_balance_ygpit_all, codes_coefs) {
8487
categories <- .assign_items()
8588
firewood_biomass <- categories$Firewood_biomass
@@ -143,6 +146,7 @@ create_n_inputs_grafs_spain <- function() {
143146
}
144147

145148
# Combine all Inputs ----------------------------------------------------------
149+
# @keywords internal
146150
.summarise_inputs <- function(n_inputs_prepared) {
147151
n_inputs <- dplyr::full_join(
148152
n_inputs_prepared$n_inputs_summary,
@@ -168,6 +172,7 @@ create_n_inputs_grafs_spain <- function() {
168172
# Summarize and calculate new columns: Prod_MgN
169173
# Spread the Destiny column to separate columns for Food,
170174
# Feed, Other_uses, Export
175+
# @keywords internal
171176
.summarise_production <- function(grafs_prod_destiny, n_inputs_sum) {
172177
grafs_prod_destiny_summary <- grafs_prod_destiny |>
173178
tidyr::pivot_wider(
@@ -200,6 +205,7 @@ create_n_inputs_grafs_spain <- function() {
200205
}
201206

202207
# NUE for Cropland and Semi-natural agroecosystems ----------------------------
208+
# @keywords internal
203209
.calculate_nue <- function(n_inputs_combined) {
204210
nue <- n_inputs_combined |>
205211
dplyr::mutate(

R/GRAFS_Prod_Destiny_git.R

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138

139139
# Production of Cropland, Livestock, and Semi natural agroecosystems ---------
140140
# Merge items with biomasses
141+
# @keywords internal
141142
.merge_items_biomass <- function(crop_area_npp_ygpit_all, npp_ygpit_csv,
142143
codes_coefs) {
143144
crop_area_npp_merged <- crop_area_npp_ygpit_all |>
@@ -161,6 +162,7 @@
161162
}
162163

163164
# Crops Production and Residues ----------------------------------------------
165+
# @keywords internal
164166
.summarise_crops_residues <- function(crop_area_npp_ygpitr_no_fallow) {
165167
crop_area_npp_prod_residue <- crop_area_npp_ygpitr_no_fallow |>
166168
dplyr::select(
@@ -194,6 +196,7 @@
194196

195197

196198
# Combining crops, residues, feed (grass, fallow) production -----------------
199+
# @keywords internal
197200
.aggregate_grazed_cropland <- function(npp_ygpit_merged,
198201
crop_area_npp_prod_residue) {
199202
grazed_data <- npp_ygpit_merged |>
@@ -256,7 +259,7 @@
256259
#'
257260
#' @return A tibble filtered and transformed with selected columns for
258261
#' semi-natural agroecosystems.
259-
#'
262+
#' @keywords internal
260263
.aggregate_seminatural_system <- function(npp_ygpit_merged) {
261264
semi_natural_agroecosystems <- npp_ygpit_merged |>
262265
dplyr::ungroup() |>
@@ -272,7 +275,7 @@
272275

273276
#' Livestock Production -------------------------------------------------------
274277
#' @param livestock_prod_ygps A data frame including livestock production data.
275-
#'
278+
#' @keywords internal
276279
.prepare_livestock_production <- function(livestock_prod_ygps) {
277280
livestock <- livestock_prod_ygps |>
278281
dplyr::select(
@@ -290,6 +293,7 @@
290293
}
291294

292295
# Combine Cropland, Semi_natural_agroecosystems and Livestock ----------------
296+
# @keywords internal
293297
.combine_production_boxes <- function(crops_residues_grazed,
294298
semi_natural_agroecosystems, livestock) {
295299
grafs_prod_combined <- dplyr::bind_rows(
@@ -313,6 +317,7 @@
313317
}
314318

315319
# Seed production per province, based on the national seed share per Area ----
320+
# @keywords internal
316321
.remove_seeds_from_system <- function(crop_area_npp_ygpit_all,
317322
pie_full_destinies_fm,
318323
grafs_prod_combined) {
@@ -367,6 +372,7 @@
367372
# Structuring dataset (GrazedWeeds und Used_Residues in ProductionFM) --------
368373
# Rename Prod_Residue_Product_Mg to Production_FM and replace Production_FM
369374
# with GrazedWeeds_MgDM (for Fallow)
375+
# @keywords internal
370376
.adding_grass_wood <- function(grafs_prod_combined_no_seeds, biomass_coefs) {
371377
grafs_prod_structured <- grafs_prod_combined_no_seeds |>
372378
dplyr::rename(Production_FM = Prod_Residue_Product_Mg) |>
@@ -462,6 +468,7 @@
462468

463469
# Processed Items ------------------------------------------------------------
464470
# Summarise processed items by Year, Province, Biomass, Item, and ProcessedItem
471+
# @keywords internal
465472
.prepare_processed_data <- function(processed_prov_fixed) {
466473
processed_data <- processed_prov_fixed |>
467474
dplyr::group_by(Year, Province_name, Name_biomass, Item, ProcessedItem) |>
@@ -480,6 +487,7 @@
480487
}
481488

482489
# Match structure of grafs_prod_combined_no_seeds ----------------------------
490+
# @keywords internal
483491
.prepare_prod_data <- function(grafs_prod_added_grass_wood,
484492
processed_data, codes_coefs_items_full) {
485493
added_grass_wood_prepared <- grafs_prod_added_grass_wood |>
@@ -509,6 +517,7 @@
509517
# Convert Fresh Matter (FM) to Dry Matter (DM) and finally to Nitrogen (N) ---
510518
# Define a list of special items that require using the primary biomass name
511519
# for selecting conversion coefficients
520+
# @keywords internal
512521
.convert_fm_dm_n <- function(added_grass_wood_merged,
513522
biomass_coefs) {
514523
special_items <- c(
@@ -572,6 +581,7 @@
572581
# Province_name and Item
573582
# Comment!!! Feed from all animals are summed together, also from pets.
574583
# Do they have to be assigned to humans?
584+
# @keywords internal
575585
.adding_feed <- function(feed_intake) {
576586
feed_intake <- feed_intake |>
577587
dplyr::select(Year, Province_name, Item, FM_Mg) |>
@@ -584,6 +594,7 @@
584594
# Popoulation: use column Pop_Mpeop_yg. Calculate the share of population ----
585595
# (population in each province divided through whole population in
586596
# Spain to get the share)
597+
# @keywords internal
587598
.calculate_population_share <- function(population_share) {
588599
population_share <- population_share |>
589600
dplyr::select(Year, Province_name, Pop_Mpeop_yg) |>
@@ -600,6 +611,7 @@
600611

601612
# Food -----------------------------------------------------------------------
602613
# Sum all Elements for Food and multiply with population share
614+
# @keywords internal
603615
.adding_food <- function(pie_full_destinies_fm, population_share) {
604616
total_food <- pie_full_destinies_fm |>
605617
dplyr::filter(Destiny == "Food", Element == "Domestic_supply") |>
@@ -623,6 +635,7 @@
623635

624636
# Other_uses -----------------------------------------------------------------
625637
# Sum all Elements for Other_uses and multiply with population share
638+
# @keywords internal
626639
.adding_other_uses <- function(pie_full_destinies_fm, population_share) {
627640
other_uses_with_share <- pie_full_destinies_fm |>
628641
dplyr::filter(Destiny == "Other_uses", Element == "Domestic_supply") |>
@@ -639,6 +652,7 @@
639652
}
640653

641654
# Putting all together -------------------------------------------------------
655+
# @keywords internal
642656
.combine_destinies <- function(grafs_prod_item, feed_intake, food_with_share,
643657
other_uses_with_share) {
644658
grafs_prod_item_combined <- grafs_prod_item |>
@@ -658,6 +672,7 @@
658672
}
659673

660674
# Converting Item and Name_biomass again and converting FM to DM, and DM to N
675+
# @keywords internal
661676
.convert_to_items_n <- function(grafs_prod_item_combined,
662677
codes_coefs_items_full, biomass_coefs) {
663678
grafs_prod_item_n <- grafs_prod_item_combined |>
@@ -692,6 +707,7 @@
692707
}
693708

694709
# Calculating Consumption and Trade ------------------------------------------
710+
# @keywords internal
695711
.calculate_trade <- function(grafs_prod_item_n) {
696712
grafs_prod_item_trade <- grafs_prod_item_n |>
697713
dplyr::group_by(Year, Province_name, Item, Name_biomass, Box) |>
@@ -711,6 +727,7 @@
711727
}
712728

713729
# Adding missing Boxes for Imports -------------------------------------------
730+
# @keywords internal
714731
.finalize_prod_destiny <- function(grafs_prod_item_trade,
715732
codes_coefs_items_full) {
716733
grafs_prod_destiny <- grafs_prod_item_trade |>

R/Typologies_Josette.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ create_typologies_of_josette <- function(
8181
#' Load input datasets ---------------------------------------------------------
8282
#' @param shapefile_path The local path where the input data are located.
8383
#' @param inputs_dir Path to the input data directory.
84-
#'
84+
#' @keywords internal
8585
.load_inputs_josette <- function(inputs_dir, shapefile_path) {
8686
layer_name <- tools::file_path_sans_ext(basename(shapefile_path))
8787

@@ -109,7 +109,7 @@ create_typologies_of_josette <- function(
109109
}
110110

111111
# Calculate food consumption and total production
112-
#
112+
# @keywords internal
113113
.calculate_consumption_prod <- function(grafs_prod_destiny_git) {
114114
# Food consumption
115115
food_consumption <- grafs_prod_destiny_git |>
@@ -143,6 +143,7 @@ create_typologies_of_josette <- function(
143143
)
144144
}
145145

146+
# @keywords internal
146147
.calculate_crop_prod_feed <- function(grafs_prod_destiny_git) {
147148
# Cropland production
148149
cropland_prod <- grafs_prod_destiny_git |>
@@ -194,7 +195,7 @@ create_typologies_of_josette <- function(
194195
#'
195196
#' @return A list containing LU per province and year, Livestock Density,
196197
#' share of imported feed
197-
#'
198+
#' @keywords internal
198199
.calculate_imported_feed <- function(
199200
livestock_df, codes_coefs_df, npp_df, feed_df, destiny_df) {
200201
lu_coefs <- .prepare_lu_coefs(codes_coefs_df)
@@ -225,7 +226,7 @@ create_typologies_of_josette <- function(
225226
}
226227

227228
# Decision: >50% animal feed from Semi-natural agroecosystems
228-
#
229+
# @keywords internal
229230
.calculate_natural_feed_share <- function(destiny_df) {
230231
seminatural_feed <- destiny_df |>
231232
dplyr::filter(Destiny == "Feed", Box == "Semi_natural_agroecosystems") |>
@@ -251,7 +252,7 @@ create_typologies_of_josette <- function(
251252

252253
# Decision: >25% animal feed from local crop ---------------------------------
253254
# Calculate domestic feed supply per province
254-
#
255+
# @keywords internal
255256
.calculate_feed_domestic_share <- function(feed_df, lu_df) {
256257
# Filter relevant feed data: Production, Exports and
257258
# Imports destined for feed use
@@ -301,7 +302,7 @@ create_typologies_of_josette <- function(
301302

302303

303304
# Decision: >25% cropland N input from manure
304-
#
305+
# @keywords internal
305306
.calculate_manure_share <- function(n_input_df) {
306307
cropland_n_inputs <- n_input_df |>
307308
dplyr::filter(Box == "Cropland") |>
@@ -322,7 +323,7 @@ create_typologies_of_josette <- function(
322323
}
323324

324325
# Assign Typologies
325-
#
326+
# @keywords internal
326327
.assign_typologies <- function(df) {
327328
df |>
328329
dplyr::mutate(
@@ -342,7 +343,7 @@ create_typologies_of_josette <- function(
342343
}
343344

344345
# Create map
345-
#
346+
# @keywords internal
346347
.create_typologies_map_josette <- function(
347348
typologies_df, shapefile_path, map_year) {
348349
layer_name <- tools::file_path_sans_ext(basename(shapefile_path))

0 commit comments

Comments
 (0)