metrumresearchgroup / pmforest

Create forest plots
https://metrumresearchgroup.github.io/pmforest
Other
2 stars 0 forks source link

`group_level` not printing when character of a number #24

Closed atredennick closed 1 year ago

atredennick commented 1 year ago

If group_level is a character of a number (e.g., "10.00") the label does not print in the plot on the y-axis. Simply adding a character to the number (e.g., "10.00 t") solves the problem. Reprex below:

Reprex

library(tidyverse)
library(pmforest)

# just a number? no dice
plot_data <- 
  tibble(
    group = c("Reference", rep(c("AGE", "WT"), each = 4)),
    group_level = "10.00"
  ) %>%
  mutate(mid = rnorm(n(), 0, 1),
         lo = mid - 0.5,
         hi = mid + 0.5)

pmforest::plot_forest(plot_data)

# add a t, and it works
plot_data <- 
  tibble(
    group = c("Reference", rep(c("AGE", "WT"), each = 4)),
    group_level = "10.00 t"
  ) %>%
  mutate(mid = rnorm(n(), 0, 1),
         lo = mid - 0.5,
         hi = mid + 0.5)

pmforest::plot_forest(plot_data)

Session info

R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] pmtables_0.5.1  pmforest_0.1.0  pmplots_0.3.5   yspec_0.5.3     here_1.0.1      forcats_0.5.2  
 [7] stringr_1.4.1   dplyr_1.0.10    purrr_0.3.5     readr_2.1.3     tidyr_1.2.1     tibble_3.1.8   
[13] ggplot2_3.3.6   tidyverse_1.3.2

loaded via a namespace (and not attached):
 [1] httr_1.4.4          bit64_4.0.5         vroom_1.6.0         jsonlite_1.8.2      modelr_0.1.9       
 [6] assertthat_0.2.1    renv_0.14.0         googlesheets4_1.0.1 cellranger_1.1.0    yaml_2.3.6         
[11] sessioninfo_1.2.2   pillar_1.8.1        backports_1.4.1     glue_1.6.2          digest_0.6.30      
[16] RColorBrewer_1.1-3  checkmate_2.1.0     rvest_1.0.3         colorspace_2.0-3    htmltools_0.5.3    
[21] pkgconfig_2.0.3     broom_1.0.1         haven_2.5.1         xtable_1.8-4        patchwork_1.1.2    
[26] scales_1.2.1        tzdb_0.3.0          googledrive_2.0.0   farver_2.1.1        generics_0.1.3     
[31] ellipsis_0.3.2      withr_2.5.0         cli_3.4.1           magrittr_2.0.3      crayon_1.5.2       
[36] readxl_1.4.1        evaluate_0.17       fs_1.5.2            fansi_1.0.3         xml2_1.3.3         
[41] tools_4.1.3         hms_1.1.2           gargle_1.2.1        lifecycle_1.0.3     munsell_0.5.0      
[46] reprex_2.0.2        compiler_4.1.3      rlang_1.0.6         grid_4.1.3          rstudioapi_0.14    
[51] labeling_0.4.2      rmarkdown_2.17      gtable_0.3.1        abind_1.4-5         DBI_1.1.3          
[56] R6_2.5.1            gridExtra_2.3       lubridate_1.8.0     knitr_1.40          bit_4.0.4          
[61] fastmap_1.1.0       utf8_1.2.2          rprojroot_2.0.3     stringi_1.7.8       parallel_4.1.3     
[66] Rcpp_1.0.9          vctrs_0.4.2         dbplyr_2.2.1        tidyselect_1.2.0    xfun_0.34       
barrettk commented 1 year ago

Hi @atredennick, thanks for reporting this! Seems some of the "hacky" code made its way into the package format. This has been addressed in #25. Once its been reviewed, we'll make sure to get this update in the next available MPN snapshot