Compilation issues to produce complex plot in RStudio

I have a graphic in RStudio that takes too long to compile up to the point after several minutes, it doesn´t produce any plot. Actually, the plot does not appear and I have to force R to stop the compilation, giving the following message (and after that RStudio doesn´t work any more):

Avisos:
1: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 
2: Removed 11 rows containing missing values or values outside the scale range
(`geom_text()`). 

However, when I run the code in RGui, it works completely fine and produce the plot in a few seconds. The reproducible minimal example is found below:

library(ggplot2)
library(ggpubr)
library(tidyverse)
library(ggpattern)
library(ggrepel)
library(ggpmisc)









ATPSTime_pry_summary <- 
structure(list(atps = structure(c(3L, 7L, 5L, 3L, 7L, 5L, 3L, 
                                  7L, 5L, 4L, 8L, 6L, 4L, 8L, 6L, 4L, 8L, 6L, 1L, 1L, 1L, 2L, 2L
), levels = c("1a", "1b", "2a", "2b", "3a", "3b", "4a", "4b"), class = "factor"), 
time = structure(c(3L, 3L, 3L, 2L, 2L, 2L, 1L, 1L, 1L, 3L, 
                   3L, 3L, 2L, 2L, 2L, 1L, 1L, 1L, 3L, 2L, 1L, 2L, 3L), levels = c("10", 
                                                                                   "30", "120"), class = "factor"), pry_mean = c(16, 10, 4, 
                                                                                                                                 11, 6, 1, 15, 8, 3, 5, 12, 17, 13, 7, 23, 2, 21, 19, 22, 
                                                                                                                                 9, 20, 14, 18), sd = c(16, 10, 4, 11, 6, 1, 15, 8, 3, 5, 
                                                                                                                                                        12, 17, 13, 7, 23, 2, 21, 19, 22, 9, 20, 14, 18), Tukey = c("a", 
                                                                                                                                                                                                                    "ab", "ab", "abc", "abc", "bc", "bc", "bc", "c", "a", "ab", 
                                                                                                                                                                                                                    "ab", "abc", "bc", "bc", "c", "c", "c", "a", "ab", "b", "b", 
                                                                                                                                                                                                                    "ab"), time_combined = structure(c(3L, 3L, 3L, 2L, 2L, 2L, 
                                                                                                                                                                                                                                                       1L, 1L, 1L, 3L, 3L, 3L, 2L, 2L, 2L, 1L, 1L, 1L, 3L, 2L, 1L, 
                                                                                                                                                                                                                                                       2L, 3L), levels = c("10", "30", "120"), class = "factor")), row.names = c(NA, 
                                                                                                                                                                                                                                                                                                                                 -23L), class = c("tbl_df", "tbl", "data.frame"))



ggplot(ATPSTime_pry_summary, aes(
  x = atps,
  y = pry_mean,
  fill = time,
  pattern = time,
  pattern_angle = time,
  group = time
)) +
  geom_col_pattern(
    position = position_dodge(0.8),
    color = "black",
    width = 0.7,
    pattern_density = 0.15,
    pattern_spacing = 0.02,
    pattern_key_scale_factor = 0.2,
    pattern_fill = "black",
    pattern_colour = NA,
    pattern_size = 0.4,  # grosor del patrón
    show.legend = TRUE
  ) +
  geom_errorbar(
    aes(ymin = pry_mean - sd, ymax = pry_mean + sd),
    position = position_dodge(0.8),
    width = 0.2,
    size = 0.8,
    alpha = 0.7,
    show.legend = FALSE
  ) +
  geom_text(
    aes(label = Tukey, y = pry_mean + sd),
    vjust = -0.5,
    size = 7.5,
    color = "gray25",
    position = position_dodge(0.8),
    show.legend = FALSE
  ) +
  scale_fill_manual(
    values = c("10" = "#d4c7ea", "30" = "#9a7dce", "120" = "#4e3182"),
    name = "Time / min"
  ) +
  scale_pattern_manual(
    values = c("10" = "none", "30" = "circle", "120" = "stripe")
  ) +
  scale_pattern_angle_manual(
    values = c("10" = 0, "30" = 0, "120" = 45)
  ) +
  guides(
    fill = guide_legend(
      override.aes = list(
        pattern = c("none", "circle", "stripe"),
        pattern_angle = c(0, 0, 45),
        pattern_fill = "black",
        pattern_density = 0.15,
        pattern_spacing = 0.07,
        pattern_size = 0.8
      )
    ),
    pattern = "none",
    pattern_angle = "none"
  ) +
  labs(
    x = "ATPS",
    y = expression(bold("Recovery Yield / %")),
    subtitle="(a)"
  ) +
  theme_bw(base_size = 20) +
  theme(
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    axis.text = element_text(size = 28),
    axis.title.x = element_text(size = 30, face = "bold"),
    axis.title.y = element_text(size = 30, face = "bold"),
    legend.title = element_text(size = 25, face = "bold"),
    legend.text = element_text(size = 23),
    legend.position="none", #legend.position = c(0.98, 0.98),
    legend.justification = c("right", "top"),
    legend.direction = "vertical",
    legend.background = element_rect(fill = "white", color = "white"),
    plot.subtitle = element_text(size = 25, face = "bold")
  ) +
  scale_y_continuous(expand = c(0, 0), limits = c(0, 25))

System Information:

  • RStudio Edition: (Desktop or Server)
  • RStudio Version: RStudio 2025.05.1+513 "Mariposa Orchid" Release (ab7c1bc795c7dcff8f26215b832a3649a19fc16c, 2025-06-01) for windows
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2025.05.1+513 Chrome/132.0.6834.210 Electron/34.5.1 Safari/537.36, Quarto 1.6.42
  • OS Version:
  • R Version: 4.5.1 (2025-06-13 ucrt)
  • sessionInfo(): <!-- R version 4.5.1 (2025-06-13 ucrt)
    Platform: x86_64-w64-mingw32/x64
    Running under: Windows 11 x64 (build 26100)

Matrix products: default
LAPACK version 3.12.1

locale:
[1] LC_COLLATE=Spanish_Spain.utf8 LC_CTYPE=Spanish_Spain.utf8
[3] LC_MONETARY=Spanish_Spain.utf8 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.utf8

time zone: Europe/Madrid
tzcode source: internal

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

loaded via a namespace (and not attached):
[1] RColorBrewer_1.1-3 R6_2.6.1 tidyselect_1.2.1 farver_2.1.2
[5] magrittr_2.0.3 gtable_0.3.6 glue_1.8.0 tibble_3.3.0
[9] pkgconfig_2.0.3 generics_0.1.4 dplyr_1.1.4 lifecycle_1.0.4
[13] ggplot2_3.5.2 cli_3.6.5 scales_1.4.0 grid_4.5.1
[17] vctrs_0.6.5 compiler_4.5.1 rstudioapi_0.17.1 tools_4.5.1
[21] cowplot_1.2.0 pillar_1.11.0 rlang_1.1.6 /-->

The memory usage is high, but I´ve tried to clear all the objects from the workspace, but every time I restart RStudio they appear again.

image


Referred here from support.rstudio.com

Seems to be running well for me in RStudio 2025.05.0+496 "Mariposa Orchid" for Ubuntu Jammy

A major difference may be that I a running R 4.5.0 under Ubuntu 24.04

 sessionInfo()
R version 4.5.0 (2025-04-11)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0  LAPACK version 3.12.0

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

time zone: America/Toronto
tzcode source: system (glibc)

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

other attached packages:
 [1] ggpmisc_0.6.2   ggpp_0.5.9      ggpattern_1.1.4 lubridate_1.9.4 forcats_1.0.0   stringr_1.5.1  
 [7] dplyr_1.1.4     purrr_1.0.4     readr_2.1.5     tidyr_1.3.1     tibble_3.3.0    tidyverse_2.0.0
[13] ggpubr_0.6.1    ggrepel_0.9.6   ggplot2_3.5.2  

loaded via a namespace (and not attached):
 [1] gtable_0.3.6       rstatix_0.7.2      lattice_0.22-5     tzdb_0.5.0         gridpattern_1.3.1 
 [6] vctrs_0.6.5        tools_4.5.0        generics_0.1.4     proxy_0.4-27       pkgconfig_2.0.3   
[11] KernSmooth_2.23-26 Matrix_1.7-3       RColorBrewer_1.1-3 lifecycle_1.0.4    compiler_4.5.0    
[16] farver_2.1.2       MatrixModels_0.5-4 carData_3.0-5      SparseM_1.84-2     class_7.3-23      
[21] quantreg_6.1       Formula_1.2-5      pillar_1.11.0      car_3.1-3          crayon_1.5.3      
[26] MASS_7.3-65        classInt_0.4-11    cachem_1.1.0       abind_1.4-8        tidyselect_1.2.1  
[31] stringi_1.8.7      sf_1.0-21          labeling_0.4.3     splines_4.5.0      fastmap_1.2.0     
[36] grid_4.5.0         cli_3.6.5          magrittr_2.0.3     survival_3.8-3     utf8_1.2.6        
[41] e1071_1.7-16       broom_1.0.8        withr_3.0.2        scales_1.4.0       backports_1.5.0   
[46] timechange_0.3.0   ggsignif_0.6.4     hms_1.1.3          memoise_2.0.1      rlang_1.1.6       
[51] Rcpp_1.0.14        DBI_1.2.3          glue_1.8.0         polynom_1.4-1      rstudioapi_0.17.1 
[56] R6_2.6.1           units_0.8-7       

[quote="daviidmpb, post:1, topic:204796"]

+
  scale_y_continuous(expand = c(0, 0), limits = c(0, 25))

Nothing to do with your problem but I think this is not correct.

+  scale_y_continuous(expand = c(0, 0), limits = c(0, 25))

Those limits drop data and you lose some error bars.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.