You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Dan,
I have been using the National Institutes of Health's (NIH) Joinpoint Regression Software (version 4.8.0.1) to analyse the trend of cancer by sex. Then, I utilised the nih.joinpoint R package to plot a regression output. Specifically, I used the jp_plot function with default parameters, which resulted in a plot displaying the trends for "Both sexes", "Females", and "Males". I attempted to customise the plots by modifying labels, colours, and axis ranges using the themes function from R. However, I encountered an issue where the customisation only applied to specific plots (e.g., only the male plot). I then tried using the patchwork package with themes, but this did not produce the desired customised plots either. As a third approach, I split the data into three subsets - "Both_sex", "Male_sex", and "Female_sex" - and applied the code below to each of these datasets separately.
#================================================
run_opt = run_options(model="ln", max_joinpoints=3, n_cores=3)
export_opt = export_options()
JP_male = joinpoint(Male_sex, x=year, y=asr, se=se,
run_opts=run_opt, export_opts=export_opt)
jp_plot(JP_male)
#=================================================
This worked only for the "Both_sex" dataset. Applying the same function to the other "Male_sex" and "Female_sex" datasets produces an error message described below.
Error in mutate( ): ℹ In argument: slope0 = na_if(apc, ".") %>% zoo::na.locf(fromLast = TRUE) %>% as_factor(). Caused by error in na_if(): ! Can't convert y<character> to match type ofx<double>. Runrlang::last_trace()` to see where the error occurred.
Q1. Is there any parameter to work around inside the jp_function ( ) to customise the plot to my requirements, such as background colour and axis title and label?
Q2. Why was the dependent variable considered a character in the error message while it is numeric in structure, as shown below?
**
data structre
str(Female_sex)
tibble [28 × 4] (S3: tbl_df/tbl/data.frame)
$ sex : chr [1:28] "Female" "Female" "Female" "Female" ...
$ year: num [1:28] 1990 1991 1992 1993 1994 ...
$ asr : num [1:28] 416 396 620 520 649 ...
$ se : num [1:28] 69.6 64.4 83.1 76.8 83.3 ...
> str(Male_sex)
tibble [28 × 4] (S3: tbl_df/tbl/data.frame)
$ sex : chr [1:28] "Male" "Male" "Male" "Male" ...
$ year: num [1:28] 1990 1991 1992 1993 1994 ...
$ asr : num [1:28] 780 569 709 678 684 ...
$ se : num [1:28] 89.6 67.7 79.9 76.4 78.6 ...
**Session info**
``` r
sessionInfo()
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
About your Q1, as stated in the documentation, jp_plot() returns either a patchwork or a list of ggplots. See the documentation of patchwork on how to change the background.
About your Q2, I don't know why you get this behavior. If you add a reprex I will probably be able to help, and correct the bug if there is one.
Hi Dan,
I have been using the National Institutes of Health's (NIH) Joinpoint Regression Software (version 4.8.0.1) to analyse the trend of cancer by sex. Then, I utilised the nih.joinpoint R package to plot a regression output. Specifically, I used the jp_plot function with default parameters, which resulted in a plot displaying the trends for "Both sexes", "Females", and "Males". I attempted to customise the plots by modifying labels, colours, and axis ranges using the themes function from R. However, I encountered an issue where the customisation only applied to specific plots (e.g., only the male plot). I then tried using the patchwork package with themes, but this did not produce the desired customised plots either. As a third approach, I split the data into three subsets - "Both_sex", "Male_sex", and "Female_sex" - and applied the code below to each of these datasets separately.
#================================================
run_opt = run_options(model="ln", max_joinpoints=3, n_cores=3)
export_opt = export_options()
JP_male = joinpoint(Male_sex, x=year, y=asr, se=se,
run_opts=run_opt, export_opts=export_opt)
jp_plot(JP_male)
#=================================================
This worked only for the "Both_sex" dataset. Applying the same function to the other "Male_sex" and "Female_sex" datasets produces an error message described below.
Error in mutate( )
: ℹ In argument:
slope0 = na_if(apc, ".") %>% zoo::na.locf(fromLast = TRUE) %>% as_factor(). Caused by error in
na_if(): ! Can't convert
y<character> to match type of
x<double>. Run
rlang::last_trace()` to see where the error occurred.Q1. Is there any parameter to work around inside the jp_function ( ) to customise the plot to my requirements, such as background colour and axis title and label?
Q2. Why was the dependent variable considered a character in the error message while it is numeric in structure, as shown below?
**
Matrix products: default
locale:
[1] LC_COLLATE=English_Australia.utf8 LC_CTYPE=English_Australia.utf8 LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C
[5] LC_TIME=English_Australia.utf8
time zone: Australia/Adelaide
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] patchwork_1.2.0 readxl_1.4.3 nih.joinpoint_0.1.0.9003 lubridate_1.9.3 forcats_1.0.0
[6] stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1
[11] tibble_3.2.1 ggplot2_3.5.1 tidyverse_2.0.0
loaded via a namespace (and not attached):
[1] gtable_0.3.5 htmlwidgets_1.6.4 devtools_2.4.5 remotes_2.5.0 lattice_0.22-6 tzdb_0.4.0 vctrs_0.6.5
[8] tools_4.4.0 generics_0.1.3 parallel_4.4.0 fansi_1.0.6 pkgconfig_2.0.3 lifecycle_1.0.4 farver_2.1.2
[15] compiler_4.4.0 munsell_0.5.1 janitor_2.2.0 snakecase_0.11.1 httpuv_1.6.15 htmltools_0.5.8.1 usethis_2.2.3
[22] crayon_1.5.2 later_1.3.2 pillar_1.9.0 urlchecker_1.0.1 ellipsis_0.3.2 cachem_1.1.0 sessioninfo_1.2.2
[29] mime_0.12 tidyselect_1.2.1 digest_0.6.35 stringi_1.8.4 labeling_0.4.3 fastmap_1.2.0 grid_4.4.0
[36] colorspace_2.1-0 cli_3.6.2 magrittr_2.0.3 pkgbuild_1.4.4 utf8_1.2.4 withr_3.0.0 scales_1.3.0
[43] promises_1.3.0 bit64_4.0.5 timechange_0.3.0 bit_4.0.5 cellranger_1.1.0 zoo_1.8-12 hms_1.1.3
[50] memoise_2.0.1 shiny_1.8.1.1 miniUI_0.1.1.1 profvis_0.3.8 rlang_1.1.3 Rcpp_1.0.12 xtable_1.8-4
[57] glue_1.7.0 pkgload_1.3.4 rstudioapi_0.16.0 vroom_1.6.5 R6_2.5.1 fs_1.6.4
The text was updated successfully, but these errors were encountered: