diff --git a/.Rbuildignore b/.Rbuildignore index d71cafa..71bcee2 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,4 @@ CONTRIBUTING.md INSTRUCTIONS_TOOL_MAINTAINERS.md UCloud_files HabitusGUIbookmark.RData +codecov.yml diff --git a/.github/workflows/r_new.yml b/.github/workflows/r_new.yml index 5c7a488..b2f8188 100644 --- a/.github/workflows/r_new.yml +++ b/.github/workflows/r_new.yml @@ -29,7 +29,7 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 diff --git a/DESCRIPTION b/DESCRIPTION index 553144b..dc61f3c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: HabitusGUI Title: R Shiny App for Processing Behavioural Data Description: Shiny app to ease processing behavioural data with research software such as GGIR, hbGPS,and hbGIS. Version: 0.3.2 -Date: 2024-03-24 +Date: 2024-03-25 Authors@R: c(person(given = "Vincent", family = "van Hees", @@ -10,7 +10,7 @@ Authors@R: email = "v.vanhees@accelting.com")) License: Apache License version 2.0 | file LICENSE Imports: shiny, shinyFiles, GGIR, bslib, methods, jsonlite, DT, - magrittr, shinyjs, callr, hbGPS, hbGIS + magrittr, shinyjs, callr, hbGPS, hbGIS, data.table Remotes: habitus-eu/hbGPS, habitus-eu/hbGIS LazyData: true Suggests: testthat, covr, rmarkdown diff --git a/NAMESPACE b/NAMESPACE index 8ae260b..38fb5e3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,7 @@ import(hbGPS) import(shiny) import(shinyFiles) importFrom(callr,r_bg) +importFrom(data.table,fread) importFrom(hbGIS,hbGIS) importFrom(jsonlite,fromJSON) importFrom(jsonlite,toJSON) diff --git a/R/GGIRshiny.R b/R/GGIRshiny.R index 0948e27..6ba6c72 100644 --- a/R/GGIRshiny.R +++ b/R/GGIRshiny.R @@ -7,12 +7,35 @@ #' @return no object is returned, only a new file is created in the output directory #' @import GGIR #' @importFrom utils write.table +#' @importFrom data.table fread #' @export #' GGIRshiny = function(rawaccdir, outputdir, sleepdiary = c(), configfile = c()) { if (length(sleepdiary) == 0) sleepdiary = c() - if (length(configfile) == 0) configfile = c() + if (length(configfile) == 0) { + configfile = c() + modeIS = "" + } else { + configfile = "D:/Dropbox/Work/sharedfolder/DATA/Habitus/GPSprocessing/JosefMarch2024/config_GGIR_counts.csv" + # extract mode from config file + config = data.table::fread(file = configfile, data.table = FALSE) + modeChar = config$value[which(config$argument == "mode")] + # check that mode is nothing more than a numeric vector + checkMode = suppressWarnings(as.numeric(gsub(x = modeChar, pattern = "c|[(]|[)]|:|,", replacement = ""))) + if (is.numeric(checkMode) == FALSE) { + stop("\nUnexpected value for parameter mode") + } else { + modeNum = eval(parse(text = modeChar)) + } + if (min(modeNum) > 0 && max(modeNum) <= 6) { + # use mode value from config file if values are plausible + modeIS = paste0(", mode = ", modeChar) + } else { + # do not use mode value and let GGIR use its default + modeIS = "" + } + } # create R script with the code to run the data analysis via a command line call # in this way turning off or restarting the app will not kill the data analysis @@ -25,10 +48,10 @@ GGIRshiny = function(rawaccdir, outputdir, sleepdiary = c(), configfile = c()) { "if (length(args) == 4) {", "GGIR::GGIR(datadir = args[1], outputdir = args[2], ", "configfile = args[3], loglocation = args[4],", - "do.parallel = TRUE)", + "do.parallel = TRUE", modeIS,")", "} else {", "GGIR::GGIR(datadir = args[1], outputdir = args[2], ", - "configfile = args[3], do.parallel = TRUE)", + "configfile = args[3], do.parallel = TRUE", modeIS,")", "}"), fileConn) close(fileConn) diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 8f5f6b3..7a7aae9 100755 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -1,12 +1,13 @@ \name{NEWS} \title{News for Package \pkg{HabitusGUI}} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} -\section{Changes in version 0.3.2 (GitHub-only-release date: 20-03-2024)}{ +\section{Changes in version 0.3.2 (GitHub-only-release date: 25-03-2024)}{ \itemize{ \item Changed default for save_ms5rawlevels in template config.csv to TRUE - \item Fix issue with old activityCounts dependency that we was not + \item Fix issue with old activityCounts dependency that was not correctly deprecated in the previous release - \item Add hbGIS parameter documentation for use inside the GUI + \item Added hbGIS parameter documentation for use inside the GUI + \item Now uses GGIR parameter mode as set by user and do not fall back on GGIR default, fixes #103 } } \section{Changes in version 0.3.1 (GitHub-only-release date: 22-01-2024)}{