Skip to contents

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)
#> Importing csv file 'C:\Users\RUNNER~1\AppData\Local\Temp\RtmpGUBArj/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 'C:\Users\RUNNER~1\AppData\Local\Temp\RtmpGUBArj/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 'C:\Users\RUNNER~1\AppData\Local\Temp\RtmpGUBArj/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 'C:\Users\RUNNER~1\AppData\Local\Temp\RtmpGUBArj/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.
umberto7_data_grouped <- kwb.umberto::group_data(umberto7_rawdata)
umberto7_data_pivot <- kwb.umberto::pivot_data(umberto7_data_grouped)
head(umberto7_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>

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)
#> Importing csv file 'D:/a/_temp/Library/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.
umberto10_data_grouped <- kwb.umberto::group_data(umberto10_rawdata)
umberto10_data_pivot <- kwb.umberto::pivot_data(umberto10_data_grouped)
head(umberto10_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.