The example .csv files (in German format, i.e. decimals are indicated
with ,
and ;
is used as field separator) were
exported from Umberto NXT (v7.1.0.13.503) and attached to the R package
kwb.umberto
as shown below:
zipfile <- system.file("extdata/umberto-nxt_v7.1.0.13.503/Beispiel_Auswertung.zip",
package = "kwb.umberto")
temp <- file.path(tempdir(), "Beispiel_Auswertung")
unzip(zipfile, exdir = temp)
dir(temp, pattern = ".csv")
#> [1] "Ref_High_C+N.csv" "Ref_High_C+high N.csv" "Ref_Low_C+N.csv"
#> [4] "Ref_Low_C+high N.csv"
Using the function kwb.umberto::import_rawdata()
and
specifying the parameter csv_dir
= temp
)
imports the model results from one .csv file that is located in the
folder /tmp/RtmpI5zszv/Beispiel_Auswertung.
rawdata <- kwb.umberto::import_rawdata(csv_dir = temp)
#> Importing csv file '/tmp/RtmpI5zszv/Beispiel_Auswertung/Ref_High_C+N.csv'
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#> Rows: 19996 Columns: 12
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (11): Project, Model, Net, Timestamp, Product, LCI Method, Phase, Proces...
#> dbl (1): Quantity
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Importing csv file '/tmp/RtmpI5zszv/Beispiel_Auswertung/Ref_High_C+high N.csv'
#>
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#>
#> Rows: 19996 Columns: 12
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (11): Project, Model, Net, Timestamp, Product, LCI Method, Phase, Proces...
#> dbl (1): Quantity
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Importing csv file '/tmp/RtmpI5zszv/Beispiel_Auswertung/Ref_Low_C+N.csv'
#>
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#>
#> Rows: 19996 Columns: 12
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (11): Project, Model, Net, Timestamp, Product, LCI Method, Phase, Proces...
#> dbl (1): Quantity
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Importing csv file '/tmp/RtmpI5zszv/Beispiel_Auswertung/Ref_Low_C+high N.csv'
#>
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#>
#> Rows: 19996 Columns: 12
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (11): Project, Model, Net, Timestamp, Product, LCI Method, Phase, Proces...
#> dbl (1): Quantity
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
To access the structure of the imported data one can run the following command:
head(rawdata)
#> project model net timestamp
#> <char> <char> <char> <char>
#> 1: POWERSTEP_LargeWWTP 0b_Ref_High_C+N Main Net 11.10.2017 13:07:54
#> 2: POWERSTEP_LargeWWTP 0b_Ref_High_C+N Main Net 11.10.2017 13:07:54
#> 3: POWERSTEP_LargeWWTP 0b_Ref_High_C+N Main Net 11.10.2017 13:07:54
#> 4: POWERSTEP_LargeWWTP 0b_Ref_High_C+N Main Net 11.10.2017 13:07:54
#> 5: POWERSTEP_LargeWWTP 0b_Ref_High_C+N Main Net 11.10.2017 13:07:54
#> 6: POWERSTEP_LargeWWTP 0b_Ref_High_C+N Main Net 11.10.2017 13:07:54
#> product
#> <char>
#> 1: VOL [A1 (P3 -> T01)] (75.000,00 m3)
#> 2: VOL [A1 (P3 -> T01)] (75.000,00 m3)
#> 3: VOL [A1 (P3 -> T01)] (75.000,00 m3)
#> 4: VOL [A1 (P3 -> T01)] (75.000,00 m3)
#> 5: VOL [A1 (P3 -> T01)] (75.000,00 m3)
#> 6: VOL [A1 (P3 -> T01)] (75.000,00 m3)
#> lci_method phase
#> <char> <char>
#> 1: ReCiPe Midpoint (H) w/o LT - climate change w/o LT, GWP100 w/o LT Other
#> 2: ReCiPe Midpoint (H) w/o LT - climate change w/o LT, GWP100 w/o LT Other
#> 3: ReCiPe Midpoint (H) w/o LT - climate change w/o LT, GWP100 w/o LT Other
#> 4: ReCiPe Midpoint (H) w/o LT - climate change w/o LT, GWP100 w/o LT Other
#> 5: ReCiPe Midpoint (H) w/o LT - climate change w/o LT, GWP100 w/o LT Other
#> 6: ReCiPe Midpoint (H) w/o LT - climate change w/o LT, GWP100 w/o LT Other
#> process material_type
#> <char> <char>
#> 1: T03: Activated sludge Bad
#> 2: T06: CHP plant Bad
#> 3: T06: CHP plant Bad
#> 4: T07: Centrifuge Bad
#> 5: T11: Electricity WWTP (RER) Bad
#> 6: T11: Electricity WWTP (RER) Bad
#> material
#> <char>
#> 1: Dinitrogen monoxide [air/unspecified]
#> 2: Dinitrogen monoxide [air/urban air close to ground]
#> 3: Methane, non-fossil [air/urban air close to ground]
#> 4: Methane, non-fossil [air/unspecified]
#> 5: Carbon dioxide, fossil [air/lower stratosphere + upper troposphere]
#> 6: Carbon dioxide, fossil [air/non-urban air or from high stacks]
#> quantity unit
#> <num> <char>
#> 1: 6.656436e+03 kg CO2-Eq
#> 2: 1.041035e+02 kg CO2-Eq
#> 3: 5.003880e+02 kg CO2-Eq
#> 4: 2.809735e+02 kg CO2-Eq
#> 5: 2.282481e-05 kg CO2-Eq
#> 6: 1.010088e+04 kg CO2-Eq
Once the data is imported into R, it can be aggregated as shown in the subsequent subchapters.
data_grouped <- kwb.umberto::group_data(rawdata)
head(data_grouped)
#> # A tibble: 6 × 5
#> # Groups: lci_method, model, process [6]
#> lci_method model process unit quantity_sum
#> <chr> <chr> <chr> <chr> <dbl>
#> 1 ReCiPe Midpoint (H) w/o LT - climate change … 0a_R… T03: A… kg C… 25498.
#> 2 ReCiPe Midpoint (H) w/o LT - climate change … 0a_R… T06: C… kg C… 607.
#> 3 ReCiPe Midpoint (H) w/o LT - climate change … 0a_R… T07: C… kg C… 277.
#> 4 ReCiPe Midpoint (H) w/o LT - climate change … 0a_R… T11: E… kg C… 12520.
#> 5 ReCiPe Midpoint (H) w/o LT - climate change … 0a_R… T12: E… kg C… 2602.
#> 6 ReCiPe Midpoint (H) w/o LT - climate change … 0a_R… T13: F… kg C… 1548.
data_pivot <- kwb.umberto::pivot_data(data_grouped)
head(data_pivot)
#> # A tibble: 6 × 6
#> # Groups: lci_method, process [6]
#> lci_method process `0a_Ref_Low_C+N` `0b_Ref_High_C+N` `0c_Ref_Low_C+high N`
#> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 ReCiPe Midpo… T03: A… 25498. 6656. 17548.
#> 2 ReCiPe Midpo… T06: C… 607. 604. 615.
#> 3 ReCiPe Midpo… T07: C… 277. 281. 284.
#> 4 ReCiPe Midpo… T11: E… 12520. 11694. 13973.
#> 5 ReCiPe Midpo… T12: E… 2602. 2556. 2666.
#> 6 ReCiPe Midpo… T13: F… 1548. 2016. 2264.
#> # ℹ 1 more variable: `0d_Ref_High_C+high N` <dbl>
data_pivot_list <- kwb.umberto::create_pivot_list(data_pivot)
#> Warning: `arrange_()` was deprecated in dplyr 0.7.0.
#> ℹ Please use `arrange()` instead.
#> ℹ See vignette('programming') for more help
#> ℹ The deprecated feature was likely used in the kwb.umberto package.
#> Please report the issue at <https://github.com/KWB-R/kwb.umberto/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Joining with `by = join_by(lci_method, process)`
#> Joining with `by = join_by(lci_method, process)`
#> Joining with `by = join_by(lci_method, process)`
#> Joining with `by = join_by(lci_method, process)`
#> Joining with `by = join_by(lci_method, process)`
#> Joining with `by = join_by(lci_method, process)`
#> Joining with `by = join_by(lci_method, process)`
#> Joining with `by = join_by(lci_method, process)`
#> Joining with `by = join_by(lci_method, process)`
head(data_pivot)
#> # A tibble: 6 × 6
#> # Groups: lci_method, process [6]
#> lci_method process `0a_Ref_Low_C+N` `0b_Ref_High_C+N` `0c_Ref_Low_C+high N`
#> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 ReCiPe Midpo… T03: A… 25498. 6656. 17548.
#> 2 ReCiPe Midpo… T06: C… 607. 604. 615.
#> 3 ReCiPe Midpo… T07: C… 277. 281. 284.
#> 4 ReCiPe Midpo… T11: E… 12520. 11694. 13973.
#> 5 ReCiPe Midpo… T12: E… 2602. 2556. 2666.
#> 6 ReCiPe Midpo… T13: F… 1548. 2016. 2264.
#> # ℹ 1 more variable: `0d_Ref_High_C+high N` <dbl>
Finally the resulting data can be exported to an EXCEL spreatsheet.
For each lci_method
available in the imported dataset a
sheet named lci_method_1
to lci_method_9
will
be created, as there are 9 distinct lci_method
available
for this example data set:
In addition a simple visualisation of the imported and grouped data
can be performed by calling the function
kwb.umberto::plot_results()
as shown below:
rawdata <- kwb.umberto::import_rawdata(csv_dir = temp)
#> Importing csv file '/tmp/RtmpI5zszv/Beispiel_Auswertung/Ref_High_C+N.csv'
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#> Rows: 19996 Columns: 12
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (11): Project, Model, Net, Timestamp, Product, LCI Method, Phase, Proces...
#> dbl (1): Quantity
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Importing csv file '/tmp/RtmpI5zszv/Beispiel_Auswertung/Ref_High_C+high N.csv'
#>
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#>
#> Rows: 19996 Columns: 12
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (11): Project, Model, Net, Timestamp, Product, LCI Method, Phase, Proces...
#> dbl (1): Quantity
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Importing csv file '/tmp/RtmpI5zszv/Beispiel_Auswertung/Ref_Low_C+N.csv'
#>
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#>
#> Rows: 19996 Columns: 12
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (11): Project, Model, Net, Timestamp, Product, LCI Method, Phase, Proces...
#> dbl (1): Quantity
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Importing csv file '/tmp/RtmpI5zszv/Beispiel_Auswertung/Ref_Low_C+high N.csv'
#>
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#>
#> Rows: 19996 Columns: 12
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (11): Project, Model, Net, Timestamp, Product, LCI Method, Phase, Proces...
#> dbl (1): Quantity
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data_grouped <- kwb.umberto::group_data(rawdata)
kwb.umberto::plot_results(grouped_data = data_grouped)