The example .csv file (in German format, i.e. decimals are indicated
with ,
and ;
is used as field separator) was
exported from Umberto LCA+ (v.10.0.3.146) and attached to the R package
kwb.umberto
as shown below:
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/RtmpNFXLU0/Rinst22fb2a4949c9/kwb.umberto/extdata/umberto-lca+_v10.1.0.3.146.
rawdata <- kwb.umberto::import_rawdata(csv_dir = temp)
#> Importing csv file '/tmp/RtmpNFXLU0/Rinst22fb2a4949c9/kwb.umberto/extdata/umberto-lca+_v10.1.0.3.146/smartech2_model-v0.1.0_input-v0.3.1.csv'
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#> Rows: 8456 Columns: 15
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (14): Project, Model, Net, Timestamp, Product, Product Name, Product Arr...
#> 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)
#> # A tibble: 6 × 15
#> project model net timestamp product product_name product_arrow
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 smartech2_model-v0.1… 0_Re… Main… 12.09.20… VOL [A… VOL A1 (P3 -> T0…
#> 2 smartech2_model-v0.1… 0_Re… Main… 12.09.20… VOL [A… VOL A1 (P3 -> T0…
#> 3 smartech2_model-v0.1… 0_Re… Main… 12.09.20… VOL [A… VOL A1 (P3 -> T0…
#> 4 smartech2_model-v0.1… 0_Re… Main… 12.09.20… VOL [A… VOL A1 (P3 -> T0…
#> 5 smartech2_model-v0.1… 0_Re… Main… 12.09.20… VOL [A… VOL A1 (P3 -> T0…
#> 6 smartech2_model-v0.1… 0_Re… Main… 12.09.20… VOL [A… VOL A1 (P3 -> T0…
#> # ℹ 8 more variables: product_flow_amount <chr>, lci_method <chr>, phase <chr>,
#> # process <chr>, material_type <chr>, material <chr>, quantity <dbl>,
#> # unit <chr>
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 … 0_Re… T03: A… kg C… 3780859.
#> 2 ReCiPe Midpoint (H) w/o LT - climate change … 0_Re… T06: C… kg C… 180612.
#> 3 ReCiPe Midpoint (H) w/o LT - climate change … 0_Re… T07: C… kg C… 289429.
#> 4 ReCiPe Midpoint (H) w/o LT - climate change … 0_Re… T14: P… kg C… 392609.
#> 5 ReCiPe Midpoint (H) w/o LT - climate change … 0_Re… T15: S… kg C… 110.
#> 6 ReCiPe Midpoint (H) w/o LT - climate change … 0_Re… T21: f… kg C… -217232.
data_pivot <- kwb.umberto::pivot_data(data_grouped)
head(data_pivot)
#> # A tibble: 6 × 3
#> # Groups: lci_method, process [6]
#> lci_method process `0_Reference_Agri`
#> <chr> <chr> <dbl>
#> 1 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T03: A… 3780859.
#> 2 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T06: C… 180612.
#> 3 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T07: C… 289429.
#> 4 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T14: P… 392609.
#> 5 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T15: S… 110.
#> 6 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T21: f… -217232.
data_pivot_list <- kwb.umberto::create_pivot_list(data_pivot)
#> 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 × 3
#> # Groups: lci_method, process [6]
#> lci_method process `0_Reference_Agri`
#> <chr> <chr> <dbl>
#> 1 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T03: A… 3780859.
#> 2 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T06: C… 180612.
#> 3 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T07: C… 289429.
#> 4 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T14: P… 392609.
#> 5 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T15: S… 110.
#> 6 ReCiPe Midpoint (H) w/o LT - climate change w/o LT… T21: f… -217232.
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/RtmpNFXLU0/Rinst22fb2a4949c9/kwb.umberto/extdata/umberto-lca+_v10.1.0.3.146/smartech2_model-v0.1.0_input-v0.3.1.csv'
#> ℹ Using "','" as decimal and "'.'" as grouping mark. Use `read_delim()` for more control.
#> Rows: 8456 Columns: 15
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ";"
#> chr (14): Project, Model, Net, Timestamp, Product, Product Name, Product Arr...
#> 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)