RStudio or not RStudio... that is the question!

RStudio is a very useful environment for development in R. However, running your script in RStudio can take much much more time than running the same in R. Let do an example with a progress bar.
Surprisingly R GUI is the fastest solution, second is RStudio and slowest is R in terminal.

library("progress")

In RStudio:
> system.time({
+     Total <- 50000
+     pb <- progress_bar$new(
+         format = "  completion [:bar] :percent eta: :eta",
+         total = Total, clear = FALSE)
+     for (annee in 1:Total) {
+         pb$tick()
+         Sys.sleep(0.0001)
+     }
+ })
  completion [========================================================================] 100% eta:  0s
utilisateur     système      écoulé 
     49.652       1.222     117.707 

In R GUI:
> system.time({
+   Total <- 50000
+   pb <- progress_bar$new(
+     format = "  completion [:bar] :percent eta: :eta",
+     total = Total, clear = FALSE)
+   for (annee in 1:Total) {
+     pb$tick()
+     Sys.sleep(0.0001)
+   }
+ })
  completion [================================================] 100% eta:  0sutilisateur     système      écoulé 
     45.570       0.856      53.106 

In R in terminal:
> system.time({
+   Total <- 50000
+   pb <- progress_bar$new(
+     format = "  completion [:bar] :percent eta: :eta",
+     total = Total, clear = FALSE)
+   for (annee in 1:Total) {
+     pb$tick()
+     Sys.sleep(0.0001)
+   }
+ })
  completion [=================================================] 100% eta:  0s
utilisateur     système      écoulé 

     45.764       0.783     121.449 

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

Install treemix in ubuntu 20.04

stepAIC from package MASS with AICc