No video

Write surprisingly fast for loops in R

  Рет қаралды 1,314

Josiah Parry

Josiah Parry

Күн бұрын

Пікірлер: 7
@gaborbakos9012
@gaborbakos9012 3 ай бұрын
A very cool video! I find loops easier to understand and use than the apply functions. However I always had a bad feeling about using them as they are supposed to be inefficient. This video made me feel better about my terrible loopy loops :).
@spacelem
@spacelem 3 ай бұрын
I do write plenty of for loops in R, but they're typically in places where either the speed really doesn't matter (e.g. `for (i in vars) ggplot(...)`) or where there's no way to vectorise the body (e.g. in stochastic simulations where there's a load of stuff going on and the loop depends on what happened in the previous loop, and I'm not that good at using `reduce()`). Typically I do what's easiest to read, and usually when something can be vectorised, it's easier to read that way anyway. If I need it to be fast, I have Julia, which says for loops are good actually since all the code is JITted, although Julia makes vectorising code trivial with its dot syntax (e.g. `log.(x)`).
@BarryRowlingsonBaz
@BarryRowlingsonBaz Жыл бұрын
At 06:01 you've got log(x)[i] in the loop which will compute all of log(x) and then take one value. Seems fixed in the benchmarks seconds later though.
@josiahparry
@josiahparry Жыл бұрын
oof! i thought i caught all of those. oops! should set eval = TRUE in the future to catch these 😅
@BarryRowlingsonBaz
@BarryRowlingsonBaz Жыл бұрын
@@josiahparry It would still work perfectly when evalled because log(x)[i] == log(x[i]) surely? :)
@jimmahgee
@jimmahgee Жыл бұрын
Turns out.... I'm bad 😅
@josiahparry
@josiahparry Жыл бұрын
That makes two of us! You’re in good company.
SLICED! Live Machine Learning
2:06:02
Josiah Parry
Рет қаралды 759
Write R functions like a pro in 6 minutes
6:46
Josiah Parry
Рет қаралды 1,2 М.
7 Days Stranded In A Cave
17:59
MrBeast
Рет қаралды 80 МЛН
Revolutionary Uses for Leftover Styrofoam
00:19
Делай сам
Рет қаралды 6 МЛН
Box jumping challenge, who stepped on the trap? #FunnyFamily #PartyGames
00:31
Family Games Media
Рет қаралды 33 МЛН
Loops using R programming
13:37
R Programming 101
Рет қаралды 12 М.
Geohash: the algorithm inside and out - Part 1
15:37
Josiah Parry
Рет қаралды 8 М.
Making R 300x times faster!
21:28
Josiah Parry
Рет қаралды 4,5 М.
Just enough C to have fun
39:29
Kay Lack
Рет қаралды 23 М.
S3 Objects and Functions in R
16:28
Josiah Parry
Рет қаралды 3,4 М.
ARRAYLIST VS LINKEDLIST
21:20
Core Dumped
Рет қаралды 58 М.
1 billion row challenge in Rust using Apache Arrow
9:12
Josiah Parry
Рет қаралды 9 М.
Demystifying . . . (dots): R package dev fundamentals
10:08
Josiah Parry
Рет қаралды 2 М.
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,6 МЛН
Introduction to Repeating Things in R: Looping Over Files
10:22