I recently updated to the latest versions of R and R Studio on my new M1 Max machine. After the update, however, Rmarkdown runs very slow compared to a regular R script, when I have largish amounts of data loaded to memory.
This is with any code I run. For example, the following code takes 0.02736592 secs on Rscript and 2.401871 secs on Rmarkdown.
library(tidyverse)
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
I have tried uninstalling and reinstalling markdown and Rmarkdown packages, and even R, Rstudio, and Anaconda but nothing is working.
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 originally posted this question on stack overflow, but didn't get any response. This is the link to the original posting: performance - Rmarkdown runs much more slowly than R script after update - Stack Overflow