-
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
#4 add plot histogram #12
#4 add plot histogram #12
Conversation
work on typos Open-Systems-Pharmacology#6 set up _pkgdown.yml (still buggy)
add plotBoxwhisker
work on typos Open-Systems-Pharmacology#6 set up _pkgdown.yml (still buggy)
add plotBoxwhisker
…eken/OSPSuite.Plots-ztcok into #4_add_plot_Histogram
@KatrinCoboeken 2 tests failed... |
translateErrorAestethics = function() { | ||
if (!private$aestheticExists(paste(private$direction, "min")) | | ||
!private$aestheticExists(paste(private$direction, "max"))) { | ||
errorType <- | ||
intersect(names(self$mapping), c("error", "error_relativ")) | ||
intersect(names(self$mapping), c("error", "error_relative")) |
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.
we should define constants for those strings (e.g. via the enumeration "ColumnNames" or whatsoever; compare
https://github.com/Open-Systems-Pharmacology/TLF-Library/blob/1a74ca24c2d318b5d1a6dc52f51121e1ca00c6c1/R/utilities-enums.R#L43-L48
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.
not necessarily in this PR, but in general
checkmate::assertDouble( | ||
ylimits, | ||
sorted = TRUE, | ||
any.missing = TRUE, | ||
len = 2, | ||
unique = TRUE, | ||
null.ok = TRUE | ||
) |
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.
I have seen this function several times, and all arguments (except the first one) are the same.
Consider introducing the function with just 1 argument ("checkAxisLimits(limits)
" or whatsoever)
initializePlot <- function(mappedData = NULL, | ||
setMapping = TRUE) { | ||
# Validation | ||
checkmate::assertClass(mappedData, classes = "MappedData", null.ok = TRUE) |
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.
for many of this checks, ospsuite.utils provides validation functions, e.g.
https://www.open-systems-pharmacology.org/OSPSuite.RUtils/reference/isOfType.html
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.
That was an intended omission
I want that the functions of this package are used and maybe copied and adjusted by people, with R experience but not so much ospsuite experience. So if there was a common known R function I have used that instead of an opsuite function.
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.
There are other reasons to use checkmate instead of the ospsuite.utils validation functions:
|
||
# check for geomUnicodeMode | ||
geomUnicodeMode <- getOption( | ||
x = "ospsuite.plots.GeomPointUnicode", |
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.
please always try to define constants for things like this
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.
I do not think to save options as constants make sense. Options are already somethign like options.
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.
I meant, define a constant for the string "ospsuite.plots.GeomPointUnicode"
and other constant strings
@@ -178,22 +244,31 @@ buildWatermarkGrob <- function(label, x = .5, y = .5, angle = 30, | |||
addXscale <- function(plotObject, | |||
xscale, | |||
xscale.args = list()) { | |||
checkmate::assertChoice(xscale, choices = c("linear", "log"), null.ok = TRUE) | |||
checkmate::assertChoice(xscale, choices = c("linear", "log", "discrete"), null.ok = TRUE) |
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.
Possible scales should be defined as enum, then validateEnumValue
from ospuite.utils can be used
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.
I can define scales as enum, but
- I prefer checkmate to validateEnumValue
- In this case you have to be careful, for some cases (like timeprofiles) only continuous x-scales like "linear" and "log" make sense other plotTypes l(like boxwhisker) accept also discrete
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.
you can still use the checkmate (or whatsoever other validation) with enums and check for concrete values, e.g.
checkmate::assertChoice(xscale, choices = c(xScales$linear, xScales$log), null.ok = TRUE)
plotObject = NULL, | ||
percentiles = getOption( | ||
x = "ospsuite.plots.Percentiles", | ||
default = getDefaultOptions()[["ospsuite.plots.Percentiles"]] |
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.
define as constant
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.
that was also about the string "ospsuite.plots.Percentiles"
R/plotHistogram.R
Outdated
) | ||
|
||
|
||
|
||
|
||
#- initialize plot | ||
plotObject <- initializePlot( | ||
mappedData | ||
) | ||
|
||
|
||
if (plotAsFrequency) { |
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.
why so many empty lines in between?
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.
I wil fix it
DESCRIPTION
Outdated
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.
What is are the reasons the package Depends
on ggplot2
and ggh4x
?(i.e why Imports
is not enough ?)
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.
Import was not enough as I used shortcuts like 'axis_minor' for ggh4x::guide_axis_minor().
I changed all such short cuts and shifted ggh4x to Import. Now it should work
R/MappedDataBoxplot.R
Outdated
#' @param mapping list of aesthetic mappings | ||
#' @param groupAesthetics vector of aesthetics, which are used for columns mapped with aesthetic `groupby` | ||
#' @param direction direction of plot either "x" or "y" | ||
#' @param isObserved Flag if TRUE mappings mdv, lloq, error and error_relative are evaluated |
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.
I never saw Flag
used in R packages or OSPS R packages to describe a boolean
/logical
. I can understand It but I'm not sure the users are really familiar with this naming.
tests/testthat/helper-for-tests.R
Outdated
@@ -1,4 +1,4 @@ | |||
# Helper for tests | |||
# Helper for tests | |||
getTestDataFilePath <- function(fileName) { | |||
dataPath <- file.path(getwd(), "..", "data", fsep = .Platform$file.sep) |
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.
Please use testthat::test_path("data", fileName)
instead, it will target tests/testthat/data/[filename]
.
As general rule, never use getwd()
or setwd()
in a package (and avoid it in general).
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.
I will delete the whole file. It is not needed in ospsuite.plots.
I copied it in an early version of my package from the ospsuite.ReportingEngine package.
- [ggplot2](https://cran.r-project.org/package=ggplot2/index.html) | ||
- [ggh4x](https://cran.r-project.org/package=ggh4x/index.html) |
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.
When installed from binary, all "Imports" and "Depends" packages will be required to be installed manually, see: https://github.com/Open-Systems-Pharmacology/OSPSuite-R#installation.
Maybe the installation part of README.Rmd
from ospsuite package could be reused here.
- change Flag to boolean - add description for installation to README.md - delete tests/testthat/Rplots.pdf and add it to .gitingnore - correct typos - delete empty lines - shift ggh4x from depends to import - delete helperForTests
Merge branch '#4_add_plot_Histogram' of https://github.com/KatrinCoboeken/OSPSuite.Plots-ztcok into #4_add_plot_Histogram
- change Flag to boolean - add description for installation to README.md - delete tests/testthat/Rplots.pdf and add it to .gitingnore - correct typos - delete empty lines - shift ggh4x from depends to import - delete helperForTests replace labelsFOrpercentiles with scales::label_ordinal Merge branch '#4_add_plot_Histogram' of https://github.com/KatrinCoboeken/OSPSuite.Plots-ztcok into #4_add_plot_Histogram fix teastfail order of linetypes in plotratiovscov.svg by fixing order of linetyps
All tests are running now, yeah 🙂 From the review comments, there are some remaining issues (s. below) - but I think those can be addressed in other PRs (I would create new issues then for them). @KatrinCoboeken So if you are not going to address any of them right now, I would approve the PR.
|
Thanks Juri,
I will adress the open issues step by step in the next days for the next pull request.
|
No description provided.