Skip to contents

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)
#> 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)
head(umberto7_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.

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)
head(umberto10_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.