I recently updated to the latest versions of R and R Studio on my new M1 Max machine. After update, however, Rmarkdown runs very slow compared to a regular R script. For example, I ran a code on R script which took this long:
user | system | Elapsed |
---|---|---|
0.437 | 0.037 | 0.490 |
When I ran the same script on Rmarkdown it took:
user | system | Elapsed |
---|---|---|
21.820 | 0.431 | 25.243 |
I have tried unistalling and reinstalling Rmarkdown package, and even R, Rstudio, and Anaconda but nothing is working.
Edit: This is with any code I run. For example,
library(tidyverse)
the following code:
start_time <- Sys.time()
mpg %>%
mutate(age = if_else(year > 2000, "New", "Old")) %>%
group_by(age) %>%
summarize(cyl = mean(cyl, na.rm = TRUE))
Sys.time() - start_time
takes 0.02736592 secs on Rscript and 2.401871 secs on Rmarkdown.
Note: This happens when I have lots of data loaded in R. For this example, I had ~3GB of data loaded in R. When there is no data loaded to memory, performance is similar.
I reinstalled the previous version of RStudio I was using (2022.07.2) and it seems to have solved the issue. It must be an issue with the recent release of Rstudio.