-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from pharmaverse/enhancement/units-edition-re…
…sults * data: correct RRLTU to a recognised character in units (Hours -> hr) * feat: setup dynamic modal table for mydata$units * fix: create indepedant reactive, still some problem in prefiltering * fix: prefiltering to exclude unitless & not requested parameters * build: connects modal_units_table in server with mydata$units when saving * build: create transform_unit function and associated tests * fix: notify when saving units table if any conversion factor is missing * refactor: modularise units table elements * refactor: modularise units table elements (module) * fix: output with custom unit values, substitute: PPORRES(U) -> PPSTRES(U) * unfinished feat: add a postNCA button to edit units also in all result outputs * refactor: make res_nca updetable for units module (reactiveEvent > reactiveVal) * refactor: lintr cleaning * documentation: improve transform unit doc and update roxygen * documentation: add units to description * fix: import entire units package so set_units and ud_are_convertible work * fix: import whole units package in NAMESPACE * fix: eliminate transform_unit dependency on units::ud_are_convertible * fix: lintr cleaning code * Apply suggestions from code review style: m-kolomanski suggested changes Co-authored-by: Mateusz Kołomański <[email protected]> * fix: small issue in analyte_choices call * fix: rename and update transform_unit > get_conversion_factor * fix: rename and update transform_unit > get_conversion_factor * refactor: req(res_nca()) instead of req(!is.null(res_nca())) * style: JS call code cleaning * refactor: units_table_server implicit actions on mydata & res_nca * documentation: update docstrings * style: call units module after res_nca is defined * style: lintr cleaning * fix: code conflicts in main * fix: res_nca as a reactiveVal instead of eventReactive * style: lint code cleaning * fix: data with merge conflict line not deleted * refactor: use describe and it functions for get_conversion_factor * style: rename test file for get_conversion_factor function * style: apply suggestions from m-kolomanski Co-authored-by: Mateusz Kołomański <[email protected]> * style: eliminate all namespacing for dplyr, shiny, base * style: lint clean code * fix: issue with DT::renderDT * fix: take off ugly not-working close button for the modal message * fix: delete unused argument in units_table module (params_to_calculate) * fix: prevent crashing when conversion_factor edition is with a non numeric * fix: notify when unit changed is not convertible * fix: instead of row, just highlight cell selections in units_table * style: lintr code cleaning * add clearance to params * fix: add cl.obs to parameters to calculate * nitpick: increase notification duration (5s to 12.5s) --------- Co-authored-by: Mateusz Kołomański <[email protected]> Co-authored-by: Spinner <[email protected]>
- Loading branch information
Showing
19 changed files
with
407 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ Imports: | |
tidyr, | ||
tools, | ||
utils, | ||
units, | ||
rlang, | ||
yaml, | ||
zip | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' Transform Units | ||
#' | ||
#' This function transforms a value from an initial unit to a target unit. | ||
#' | ||
#' @param initial_unit A character string representing the initial unit. | ||
#' @param target_unit A character string representing the target unit. | ||
#' @returns A numeric value for the conversion factor from the initial to the target unit, | ||
#' or NA if the units are not convertible. | ||
#' @examples | ||
#' get_conversion_factor("meter", "kilometer") | ||
#' get_conversion_factor("sec", "min") | ||
#' @importFrom units set_units | ||
#' @export | ||
get_conversion_factor <- Vectorize(function(initial_unit, target_unit) { | ||
tryCatch({ | ||
conversion <- units::set_units( | ||
units::set_units(1, initial_unit, mode = "standard"), | ||
target_unit, mode = "standard" | ||
) | ||
unname(as.numeric(conversion)) | ||
}, error = function(e) { | ||
if (initial_unit == target_unit) { | ||
1 | ||
} else { | ||
NA | ||
} | ||
}) | ||
}, USE.NAMES = FALSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.