For downloading the latest
(from
Martin Systems webportal
) and archived
(from
KWB Nextcloud
) .tsv
data files you need set
the following environment variables
only once as shown below.
For doing so follow the steps below:
Open RStudio
and run
usethis::edit_r_environ()
In the opened window add the required environment variables
MBR40_URL = "url-to-download-pilot-plant-data"
NEXTCLOUD_URL = "https://<replace-with-dwc-cloud-url>"
NEXTCLOUD_USER = "<your-dwc-cloud-username>" # your username
NEXTCLOUD_PASSWORD = "your-nextcloud-app-password" ### see details below
To access the archived
data you need to be a registered
Nextcloud user with access to the folder
projects/MBR4.0
For creating <your-nextcloud-app-password>
:
go to: https://replace-with-kwb-cloud-url/index.php/settings/user/security
scroll down to create new app password
select a name e.g. r-script
and copy the token and
replace your-nextcloud-app-password
Subsequently click Save and restart RStudio.
For running the shiny app it is needed to setup the environment variables as shown above and run the following code.
To use the latest data
(downloads data from web) or if
you run the app for the first time you need to run:
For performing data aggregation and export to post-process the data
in Excel
in a wide
format the workflow defined
below has to be followed.
In paths_list
you need to replace the dummy value
kwb-server
for the key servername
.
#KWB server
paths_list <- list(
servername = "kwb-server",
root = "//<servername>/projekte$/WWT_Department/Projects/MBR 4.0/Exchange/",
rawdata = "<root>/20_rawdata",
processing = "<root>/21_processing",
online = "<rawdata>/online_data",
export_dir = "<processing>/online-data"
)
if(dir.exists(paths$online)) {
paths <- kwb.utils::resolve(paths_list)
}
paths_list <- list(
root = "C:/kwb/projects/mbr4.0",
rawdata = "<root>/20_rawdata",
processing = "<root>/21_processing",
online = "<rawdata>/online_data",
export_dir = "<processing>/online-data"
)
# Only execute "At Home" if not at "KWB" (i.e. KWB server path does not exist)
fs::dir_create(paths$online, recurse = TRUE)
paths <- kwb.utils::resolve(paths_list)
Raw and aggregated data will be exported as csv
in
wide
format (by running
kwb.pilot::long_to_wide()
) as shown below:
kwb.pilot::export_data(df_long = mbr4_data_tidy_raw,
export_dir = paths$export_dir)
kwb.pilot::export_data(df_long = mbr4_data_tidy_list_10min,
export_dir = paths$export_dir)
kwb.pilot::export_data(df_long = mbr4_data_tidy_list_hour,
export_dir = paths$export_dir)
Finally you can check the datasets in the export folder by running: