@@ -468,12 +468,14 @@ Convergence_Plot <- function(
468468
469469 FileConv_Beta <- IASDT.R :: Path(Path_Convergence , " Convergence_Beta.RData" )
470470
471-
472471 if (file.exists(FileConv_Beta )) {
473472
474473 IASDT.R :: CatTime(" Loading plotting data" , Level = 1 )
475474 PlotObj_Beta <- IASDT.R :: LoadAs(FileConv_Beta )
476475
476+ rm(Obj_Beta , envir = environment())
477+ invisible (gc())
478+
477479 } else {
478480
479481 HTML1 <- " <span style='color:blue;'><b>"
@@ -497,6 +499,7 @@ Convergence_Plot <- function(
497499 HTML1 <- " <span style='color:blue;'><b>"
498500 HTML2 <- " </b></span><span style='color:grey;'>"
499501 HTML3 <- " </span>"
502+ HTML4 <- " — "
500503 VarsDesc <- tibble :: tribble(
501504 ~ Variable , ~ VarDesc ,
502505 " bio1" , " annual mean temperature" ,
@@ -525,9 +528,9 @@ Convergence_Plot <- function(
525528 " {HTML1}{stringr::str_to_sentence(Variable)}\\
526529 {HTML2} [{VarDesc}]{HTML3} - {Term}" ),
527530 VarDesc = stringr :: str_replace(
528- VarDesc , " - L$" , "   &mdash  Linear " ),
531+ VarDesc , " - L$" , paste0( HTML4 , " Linear " ) ),
529532 VarDesc = stringr :: str_replace(
530- VarDesc , " - Q$" , "   &mdash  Quadratic " ),
533+ VarDesc , " - Q$" , paste0( HTML4 , " Quadratic " ) ),
531534 Variable = paste0(Variable , " _" , Term ),
532535 Term = NULL ) %> %
533536 dplyr :: bind_rows(LinearTerms )
@@ -629,9 +632,6 @@ Convergence_Plot <- function(
629632
630633 # Prepare working on parallel
631634 IASDT.R :: Set_parallel(NCores = min(NCores , nrow(Beta_DF )), Level = 2 )
632- if (.Platform $ OS.type == " windows" ) {
633- on.exit(try(snow :: stopCluster(" c1" ), silent = TRUE ), add = TRUE )
634- }
635635 on.exit(future :: plan(" future::sequential" , gc = TRUE ), add = TRUE )
636636
637637 # # |||||||||||||||||||||||||||||||||||||||||||||||||||||||| ##
@@ -773,7 +773,7 @@ Convergence_Plot <- function(
773773 # # |||||||||||||||||||||||||||||||||||||||||||||||||||||||| ##
774774
775775 # Stopping cluster
776- IASDT.R :: Set_parallel(Stop = TRUE , Cat = TRUE , Level = 2 )
776+ IASDT.R :: Set_parallel(Stop = TRUE , Level = 2 )
777777
778778 rm(Beta_DF , BetaNames , envir = environment())
779779 invisible (gc())
@@ -803,17 +803,15 @@ Convergence_Plot <- function(
803803 # Prepare working on parallel
804804 IASDT.R :: Set_parallel(
805805 NCores = min(NCores , nrow(BetaTracePlots_ByVar )), Level = 2 )
806-
807- if (.Platform $ OS.type == " windows" ) {
808- on.exit(try(snow :: stopCluster(" c1" ), silent = TRUE ), add = TRUE )
809- }
810806 on.exit(future :: plan(" future::sequential" , gc = TRUE ), add = TRUE )
811807
812808 # # |||||||||||||||||||||||||||||||||||||||||||||||||||||||| ##
813809
814810 IASDT.R :: CatTime(" Save plots" , Level = 2 )
811+ VarNames <- BetaTracePlots_ByVar $ Variable
812+
815813 BetaTracePlots_ByVar0 <- future.apply :: future_lapply(
816- X = BetaTracePlots_ByVar $ Variable ,
814+ X = VarNames ,
817815 FUN = function (x ) {
818816
819817 VarDesc <- BetaTracePlots_ByVar %> %
@@ -903,16 +901,16 @@ Convergence_Plot <- function(
903901 future.seed = TRUE ,
904902 future.globals = c(" BetaTracePlots_ByVar" , " NRC" , " Path_Convergence" ),
905903 future.packages = c(
906- " dplyr " , " ggplot2 " , " magrittr " , " purrr" , " IASDT.R " , " ggtext" ,
907- " tibble" , " tidyr " , " cowplot " , " grid " ))
904+ " tidyr " , " dplyr " , " ggplot2 " , " purrr" , " ggtext" ,
905+ " tibble" , " cowplot " , " grDevices " , " IASDT.R " ))
908906
909907 rm(BetaTracePlots_ByVar0 , BetaTracePlots_ByVar , envir = environment())
910908 invisible (gc())
911909
912910 # # |||||||||||||||||||||||||||||||||||||||||||||||||||||||| ##
913911
914912 # Stopping cluster
915- IASDT.R :: Set_parallel(Stop = TRUE , Cat = TRUE , Level = 2 )
913+ IASDT.R :: Set_parallel(Stop = TRUE , Level = 2 )
916914
917915 # # ..................................................................... ###
918916
@@ -933,10 +931,6 @@ Convergence_Plot <- function(
933931 # Prepare working on parallel
934932 IASDT.R :: Set_parallel(
935933 NCores = min(NCores , nrow(BetaTracePlots_BySp )), Level = 2 )
936-
937- if (.Platform $ OS.type == " windows" ) {
938- on.exit(try(snow :: stopCluster(" c1" ), silent = TRUE ), add = TRUE )
939- }
940934 on.exit(future :: plan(" future::sequential" , gc = TRUE ), add = TRUE )
941935
942936 # # |||||||||||||||||||||||||||||||||||||||||||||||||||||||| ##
@@ -1018,17 +1012,17 @@ Convergence_Plot <- function(
10181012 rm(PlotTitle , envir = environment())
10191013 return (invisible (NULL ))
10201014 },
1021- future.scheduling = 1 , future. seed = TRUE ,
1015+ future.seed = TRUE ,
10221016 future.globals = c(
10231017 " MarginType" , " BetaTracePlots_BySp" , " Path_Convergence_BySp" , " Beta_NRC" ),
10241018 future.packages = c(
10251019 " dplyr" , " coda" , " ggplot2" , " ggExtra" , " ggtext" , " IASDT.R" ,
1026- " stringr" , " gtools" , " cowplot" , " purrr" ))
1020+ " stringr" , " gtools" , " cowplot" , " purrr" , " grDevices " ))
10271021
10281022 # # |||||||||||||||||||||||||||||||||||||||||||||||||||||||| ##
10291023
10301024 # Stopping cluster
1031- IASDT.R :: Set_parallel(Stop = TRUE , Cat = TRUE , Level = 2 )
1025+ IASDT.R :: Set_parallel(Stop = TRUE , Level = 2 )
10321026
10331027 rm(BetaTracePlots_BySp0 , envir = environment())
10341028
0 commit comments