Package 'kwb.umberto'

Title: R package supporting UMERTO LCA at KWB
Description: Helper functions for data import, aggregation and visualisation of UMBERTO (https://www.ifu.com/umberto/) model output.
Authors: Michael Rustler [aut, cre] , Hauke Sonnenberg [ctb] , FAKIN [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph]
Maintainer: Michael Rustler <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2024-10-31 05:52:25 UTC
Source: https://github.com/KWB-R/kwb.umberto

Help Index


Create pivot list

Description

Create pivot list

Usage

create_pivot_list(pivot_data, arrange_cols = "process")

Arguments

pivot_data

privot data as retrieved from function pivot_data()

arrange_cols

columns used for arranging the data (default: "process")

Value

a list of results, where each element contains the result table for one lci_method

Examples

zipfile <- system.file("extdata/umberto-nxt_v7.1.0.13.503/Beispiel_Auswertung.zip", 
package = "kwb.umberto")
umberto7_csv_dir <- file.path(tempdir(), "Beispiel_Auswertung")
unzip(zipfile, exdir = umberto7_csv_dir)
umberto7_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto7_csv_dir)
umberto7_data_grouped <- kwb.umberto::group_data(umberto7_rawdata)
umberto7_data_pivot <- kwb.umberto::pivot_data(umberto7_data_grouped)
umberto7_data_pivot_list <- kwb.umberto::create_pivot_list(umberto7_data_pivot)
head(umberto7_data_pivot_list)

umberto10_csv_dir <- system.file("extdata/umberto-lca+_v10.1.0.3.146", 
package = "kwb.umberto")
umberto10_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto10_csv_dir)
umberto10_data_grouped <- kwb.umberto::group_data(umberto10_rawdata)
umberto10_data_pivot <- kwb.umberto::pivot_data(umberto10_data_grouped)
umberto10_data_pivot_list <- kwb.umberto::create_pivot_list(umberto10_data_pivot)
head(umberto10_data_pivot_list)

Group data

Description

Group data

Usage

group_data(
  raw_data,
  grouping_paras = c("lci_method", "model", "process", "unit"),
  grouping_function = "sum",
  summarise_col = "quantity"
)

Arguments

raw_data

as retrieved by function import_rawdata()

grouping_paras

cleaned column names used for grouping. (default: c("lci_method", "model", "process", "unit"))

grouping_function

R function used for grouping (default: "sum")

summarise_col

column name used for summarising (default: "quantity"), i.e. for which the "grouping_function" should be applied

Value

aggregated data according

Examples

zipfile <- system.file("extdata/umberto-nxt_v7.1.0.13.503/Beispiel_Auswertung.zip", 
package = "kwb.umberto")
umberto7_csv_dir <- file.path(tempdir(), "Beispiel_Auswertung")
unzip(zipfile, exdir = umberto7_csv_dir)
umberto7_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto7_csv_dir)
umberto7_data_grouped <- kwb.umberto::group_data(umberto7_rawdata)
head(umberto7_data_grouped )

umberto10_csv_dir <- system.file("extdata/umberto-lca+_v10.1.0.3.146", 
package = "kwb.umberto")
umberto10_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto10_csv_dir)
umberto10_data_grouped <- kwb.umberto::group_data(umberto10_rawdata)
head(umberto10_data_grouped)

Import rawdata

Description

Import rawdata

Usage

import_rawdata(csv_dir, sep = ";", ...)

Arguments

csv_dir

path to directory with .csv files

sep

Single character used to separate fields within a record (default: in GERMAN format, i.e. sep = ";")

...

further arguments passed to either readr::read_csv2 (default for sep == ';') or readr::read_csv (if sep == ',')

Value

data.frame with all imported raw data

Examples

zipfile <- system.file("extdata/umberto-nxt_v7.1.0.13.503/Beispiel_Auswertung.zip", 
package = "kwb.umberto")
umberto7_csv_dir <- file.path(tempdir(), "Beispiel_Auswertung")
unzip(zipfile, exdir = umberto7_csv_dir)
umberto7_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto7_csv_dir)
head(umberto7_rawdata)

umberto10_csv_dir <- system.file("extdata/umberto-lca+_v10.1.0.3.146", 
package = "kwb.umberto")
umberto10_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto10_csv_dir)
head(umberto10_rawdata)

Make pivot data

Description

Make pivot data

Usage

pivot_data(
  rawdata_grouped,
  cols_to_ignore = "unit",
  key_col = "model",
  value_col = "quantity_sum"
)

Arguments

rawdata_grouped

grouped rawdata as retrieved by function group_data()

cols_to_ignore

column names not to be considered for transforming the data from the "list" to the "wide" format with tidyr::spread() (default: "unit")

key_col

column name containing the key for transforming the data from the "list" to the "wide" format with tidyr::spread() (default: "model")

value_col

column name containing the values that will be used during transforming the data from the "list" to the "wide" format with tidyr::spread() (default: "quantity_sum")

Value

data.frame with the aggregated results for all different"lci_method"

Examples

zipfile <- system.file("extdata/umberto-nxt_v7.1.0.13.503/Beispiel_Auswertung.zip", 
package = "kwb.umberto")
umberto7_csv_dir <- file.path(tempdir(), "Beispiel_Auswertung")
unzip(zipfile, exdir = umberto7_csv_dir)
umberto7_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto7_csv_dir)
umberto7_data_grouped <- kwb.umberto::group_data(umberto7_rawdata)
umberto7_data_pivot <- kwb.umberto::pivot_data(umberto7_data_grouped)
head(umberto7_data_pivot)

umberto10_csv_dir <- system.file("extdata/umberto-lca+_v10.1.0.3.146", 
package = "kwb.umberto")
umberto10_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto10_csv_dir)
umberto10_data_grouped <- kwb.umberto::group_data(umberto10_rawdata)
umberto10_data_pivot <- kwb.umberto::pivot_data(umberto10_data_grouped)
head(umberto10_data_pivot)

Plot results

Description

Plot results

Usage

plot_results(
  grouped_data,
  x_col = "model",
  y_col = "quantity_sum",
  fill_col = "process"
)

Arguments

grouped_data

data.frame with grouped rawdata as retrieved by function group_data()

x_col

column name to be used for plotting on x-axis (default: "model")

y_col

column name to be used for plotting on y-axis (default: "quantity_sum")

fill_col

column name to be used for filling (default: "process")

Value

simple plots for all different groups

Examples

zipfile <- system.file("extdata/umberto-nxt_v7.1.0.13.503/Beispiel_Auswertung.zip", 
package = "kwb.umberto")
umberto7_csv_dir <- file.path(tempdir(), "Beispiel_Auswertung")
unzip(zipfile, exdir = umberto7_csv_dir)
umberto7_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto7_csv_dir)
umberto7_data_grouped <- kwb.umberto::group_data(umberto7_rawdata)
kwb.umberto::plot_results(grouped_data = umberto7_data_grouped)

umberto10_csv_dir <- system.file("extdata/umberto-lca+_v10.1.0.3.146", 
package = "kwb.umberto")
umberto10_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto10_csv_dir)
umberto10_data_grouped <- kwb.umberto::group_data(umberto10_rawdata)
kwb.umberto::plot_results(grouped_data = umberto10_data_grouped)

Write results to EXCEL

Description

Write results to EXCEL

Usage

write_xlsx(data_pivot_list, path = "results.xlsx")

Arguments

data_pivot_list

a list as retrieved by function create_pivot_list()

path

relative or full path to be used for exporting the results to EXCEL (default: "results.xlsx")

Value

writes results in EXCEL file defined in "path", where each sheet

Examples

zipfile <- system.file("extdata/umberto-nxt_v7.1.0.13.503/Beispiel_Auswertung.zip", 
package = "kwb.umberto")
umberto7_csv_dir <- file.path(tempdir(), "Beispiel_Auswertung")
unzip(zipfile, exdir = umberto7_csv_dir)
umberto7_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto7_csv_dir)
umberto7_data_grouped <- kwb.umberto::group_data(umberto7_rawdata)
umberto7_data_pivot <- kwb.umberto::pivot_data(umberto7_data_grouped)
umberto7_data_pivot_list <- kwb.umberto::create_pivot_list(umberto7_data_pivot)
export_path <- file.path(getwd(), "umberto7_results.xlsx")
print(sprintf("Exporting aggregated results to %s", export_path))
write_xlsx(umberto7_data_pivot_list, path = export_path)

umberto10_csv_dir <- system.file("extdata/umberto-lca+_v10.1.0.3.146", 
package = "kwb.umberto")
umberto10_rawdata <- kwb.umberto::import_rawdata(csv_dir = umberto10_csv_dir)
umberto10_data_grouped <- kwb.umberto::group_data(umberto10_rawdata)
umberto10_data_pivot <- kwb.umberto::pivot_data(umberto10_data_grouped)
umberto10_data_pivot_list <- kwb.umberto::create_pivot_list(umberto10_data_pivot)
export_path <- file.path(getwd(), "umberto10_results.xlsx")
print(sprintf("Exporting aggregated results to %s", export_path))
write_xlsx(umberto10_data_pivot_list, path = export_path)