-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes #31 wrapper functions for waist/hip and waist/height ratio #33
base: main
Are you sure you want to change the base?
Conversation
Please don’t judge too harshly, this is my first Pull Request ever. I would need help with unit tests and other stuff as I have no experience at all. |
@manciniedoardo Need help with |
@AndersAskeland can you look as well pls? |
@yurovska It fails as the units package depends on a system dependency of "udunits2". This library must be manually installed in Unix (test suite that fails is running this) and MacOS. On Windows it is included in RTools as "bin\udunits2.exe". As such, we unfortunately cannot use the I think the concept of allowing different units is important, as one cannot always control what the collected/SDTM units are. I would actually argue that this functionality should be included in admiral base at some point As for alternative approaches than using the units package, I can personally think of two potential solutions. Either we do manual unit conversion inside the wrapper functions (probably messy to have all potential units conversions inside I think that we might need to discuss this before implementation though, and maybe create a separate issue and pull request. |
@AndersAskeland I'm on MacOS and just did
It's a pity. |
@AndersAskeland Just tested it also within Roche environment (Ubuntu 22.04 Jammy). No issues. Do you really think > renv::install("units", repos = "https://packages.roche.com/Validated-4.3/latest")
# Downloading packages -------------------------------------------------------
- Downloading units from CRAN ... OK [file is up to date]
Successfully downloaded 1 package in 1.3 seconds.
The following package(s) will be installed:
- units [0.8-5]
These packages will be installed into "~/R/x86_64-pc-linux-gnu-library/4.3".
Do you want to proceed? [Y/n]: Y
# Installing packages --------------------------------------------------------
- Installing units ... OK [installed binary and cached in 1.9s]
Successfully installed 1 package in 2 seconds.
> library(units)
udunits database from /usr/share/xml/udunits/udunits2.xml
> val_cm <- set_units(1:10, cm)
> val_cm
Units: [cm]
[1] 1 2 3 4 5 6 7 8 9 10
> val_mm <- set_units(1:10, mm)
> val_mm
Units: [mm]
[1] 1 2 3 4 5 6 7 8 9 10
> val_cm - val_mm
Units: [cm]
[1] 0.9 1.8 2.7 3.6 4.5 5.4 6.3 7.2 8.1 9.0 |
I would guess most compute environment have it installed. However, I still feel that we cannot expect all users to have this library or possibility of building it from source. I noticed that in our compute environment, when first installing So while it might usually work, we would put a requirement on users to have a working C compiler, which is not always the case. For example for Mac, I think the brew process (or MacOS developer tools) installs the required compilers, however, if you just install R with nothing else, I am unsure if it will work. There might also be a difference on ARM Macs. If we however take a step back and look at what it is used for, is it only for converting meters/mm/cm/inches? Do you use it for more? |
@AndersAskeland Re-written without use of |
@yurovska Nice! I will start looking at the pull request. It might take some time, as this is the first time reviewing functions in Admiral and I need to figure out the general layout and stuff :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @yurovska! I left some general comments; @AndersAskeland will do a technical review.
Additionally:
- please take this opportunity to remove
hello_admiral()
and related tests/documentation as we now have a real function. - please ensure the functions appear on the reference page and take the opportunity to tidy up the reference page if you can - happy to help on this front if needed.
- add tests for the ratio function too, otherwise the test coverage for the package will be low.
Co-authored-by: Edoardo Mancini <[email protected]>
Co-authored-by: Edoardo Mancini <[email protected]>
@manciniedoardo Thanks for your review. I already started addressing commit suggestions. Will be ready soon. Regarding the bullet points above:
|
I would still think we need to do something for non-exported functions, especially on derive_var_ratio, as it is somewhat advanced. I also believe that covr by default include non-exported functions. How are you running the R CMD check? Is it working when running |
Hm, I tried it out again and it now works fine. Probably, I'm confusing the unit tests with |
Glad it's fixed! Yeah any function in the package should have unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @yurovska !
Here are some initial comments. Feel free to push back if you disagree, I can sometimes be persuaded to change my opinions :)
I also want to check the code again after we implement the changes.
Co-authored-by: Anders Askeland <[email protected]>
@AndersAskeland @manciniedoardo Thanks again for your valuable review. I think I'm done addressing all your comments and the PR is ready for the next (or maybe final) round. I haven't resolved some conversations, please do so if you agree with the update made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - a couple of minor comments to implement but then I am happy from a documentation and user side. @AndersAskeland and @pharmaverse/admiralmetabolic pls add your final feedback and any technical by end of week so we can then merge.
5910b8e
to
1d649f8
Compare
Sorry for my late review, I was suddenly required to travel out of office for most of the week. I will quickly go through it tomorrow :) I have been thinking about one thing though, which I think we shouldn’t necessarily change now, but could alter in the future depending on your thoughts on it. My thoughts have been about the design/implementation of the actual conversion, and weather that should be something associated to the actual weight height / waist hip ratio, or should be more general and associated with the ratio function (which it is now). We had a short discussion about me wanting the conversion function to fail if conversion was not supported, but you (rightly) pointed out that there are ratios that we should not convert (for instance kg/m). I still agree that this is something we should cater to . However, I am thinking about cases where you might be interested in a ratio with convertible units. For instance a meter / centimetre ratio. I realise that this is very uncommon and strange, but my thoughts are then, who are we to decide which ratios to allow? Hence, I think we should at some point discuss if we should keep the ratio function extremely generic and move everthing associated to conversion to the wrapper function. In some sense I think this makes more sense, because, we would not un necessarily call a convert function when not needed, and we could be more consistent with the return from the unit conversion function. I am not a big fan of a function being able to return NAs. But… For time sakes, and to allow us to implement this before next week, I think we can discuss this later as it would not actually impede the functions to change the implementation. |
Thanks in advance for finding time to finalize the review. I got your point and I think I have an idea. What if we add a sort of |
Thank you for your Pull Request! We have developed this task checklist from the Development Process Guide to help with the final steps of the process. Completing the below tasks helps to ensure our reviewers can maximize their time on your code as well as making sure the admiral family codebase remains robust and consistent.
Please check off each taskbox as an acknowledgment that you completed the task or check off that it is not relevant to your Pull Request. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the
main
branch until you have checked off each task.styler::style_file()
to style R and Rmd filesdevtools::document()
so all.Rd
files in theman
folder and theNAMESPACE
file in the project root are updated appropriatelyNEWS.md
under the header# admiral<ext> (development version)
if the changes pertain to a user-facing function (i.e. it has an@export
tag) or documentation aimed at users (rather than developers)pkgdown::build_site()
and check that all affected examples are displayed correctly and that all new functions occur on the Reference page.lintr::lint_package()
R CMD check
locally and address all errors and warnings -devtools::check()