Skip to content

Commit

Permalink
Improve chart side initialization when there are child data (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefvanbuuren committed May 8, 2024
1 parent e4998db commit 3501581
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions R/convert_tgt_chartadvice.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#' @author Stef van Buuren 2020
#' @seealso [chartcatalog::parse_chartcode()]
#' @keywords server
#' @examples
#' test25 <- system.file("extdata/bds_v3.0/test/test25.json", package = "jamesdemodata")
#' james:::convert_tgt_chartadvice(txt = test25)
#' @export
convert_tgt_chartadvice <- function(txt = "",
session = "",
Expand Down
14 changes: 6 additions & 8 deletions R/select_chart.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ select_chart <- function(target = NULL,
sex = NULL,
etn = NULL,
ga = NULL,
side = "hgt",
side = NULL,
language = "dutch") {

# choose defaults depending on individual
Expand Down Expand Up @@ -66,13 +66,11 @@ select_chart <- function(target = NULL,

select_side <- function(tgt) {
yname <- timedata(tgt)[["yname"]]
if (any(c("hgt", "wgt", "hdc") %in% yname)) {
return("hgt")
}
if (any(c("dsc") %in% yname)) {
return("dsc")
}
"hgt"
gro <- intersect(yname, c("hgt", "wgt", "hdc", "bmi", "wfh"))
dev <- intersect(yname, c("dsc"))
if (length(gro)) return(gro[1L])
if (length(dev)) return(dev[1L])
return("hgt")
}

select_ga <- function(tgt) {
Expand Down

0 comments on commit 3501581

Please sign in to comment.