knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
# Enable repository from kwb-r options(repos = c( kwbr = 'https://kwb-r.r-universe.dev', CRAN = 'https://cloud.r-project.org')) # Download and install kwb.umberto in R install.packages('kwb.umberto')
library(kwb.umberto)
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")
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 r temp
.
rawdata <- kwb.umberto::import_rawdata(csv_dir = temp)
To access the structure of the imported data one can run the following command:
head(rawdata)
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)
data_pivot <- kwb.umberto::pivot_data(data_grouped) head(data_pivot)
data_pivot_list <- kwb.umberto::create_pivot_list(data_pivot) head(data_pivot)
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:
r sprintf("\n- %s\n", unique(rawdata$lci_method))
export_path <- file.path(temp, "results.xlsx") print(sprintf("Exporting aggregated results to %s", export_path)) write_xlsx(data_pivot_list, path = export_path)
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) data_grouped <- kwb.umberto::group_data(rawdata) kwb.umberto::plot_results(grouped_data = data_grouped)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.