Is an advantage of R over other languages that R is vectorized?
Sure. But many other languages are also vectorized, Matlab for example. And, if I remember correctly, APL.
Not so much as it is vectorized as that it presents interactively as functional, so that instead of a for()
loop, you can do things like
``` r
apply(mtcars,2,sd)
#> mpg cyl disp hp drat wt
#> 6.0269481 1.7859216 123.9386938 68.5628685 0.5346787 0.9784574
#> qsec vs am gear carb
#> 1.7869432 0.5040161 0.4989909 0.7378041 1.6152000
Created on 2023-11-21 with reprex v2.0.2
Basic operations are vectorized, as in
a <- runif(1000)
b <- runif(1000)
c <- a+b
Adds the two 1,000-long vectors.
+
is a function, too
This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.