Make your R code 18,878 times faster! (Unabridged) | R Programming

Опубликовано: 08 Март 2025
на канале: Dynamic Data Script
3,832
100

We show you exactly how we achieved this! Optimizing your code for performance can mean waiting a few minutes instead of days for your code to run. For loops, dataframes, lists, linear algebra, dplyr package and datatable package are all compared. In this detailed version of the tutorial, we will manipulate the same data in 6 different ways and demonstrate how and why these algorithms differ so much. We also compare different scales of datasets! Check out the channel to learn how you can make your R code faster with Julia, Python and SQL. 🏎️

💾 Get the code here: https://github.com/MaximeRivest/How-t...
🌋 R Inferno: https://www.burns-stat.com/pages/Tuto...
00:00 Introduction and overview
01:25 Goal and dataset
1st approach: Growing a vector with for loops
02:46 for loops: Code walkthrough
05:49 for loops: Timing and explanation
2nd approach: Dataframe pre-allocation
07:08 Pre-allocation: Code walkthrough
08:25 Pre-allocation: Timing and explanation
3rd approach: Lists - vectorization
08:58 Vectorization: Code walkthrough
19:52 Vectorization: Timing and explanation
4th approach: Linear algebra - matrices
21:06 Linear algebra: Code walkthrough
30:20 Linear algebra: Timing and explanation
5th approach: dplyr package
33:23 dplyr: Code walkthrough
37:29 dplyr: Timing and explanation
6th approach: datatable package
37:41 datatable: Code walkthrough
43:18 datatable: Timing and explanation
Benchmarking
44:00 Cross comparisons
46:35 Comparison with new random dataset
48:31 Comparison with new random double size dataset
49:51 Tips and tricks for optimization

🏎️ R performance playlist    • R Programming - Performance  

🧮 dplyr playlist    • dplyr  

#R #Rtutorial #Rprogramming #RStats #performance #tidyverse #dplyr #RStudio #datascience #DDS #DDSR #datatable #r4ds