I'm still learning R. Is there some automated way to identify if an R operation or a function is vectorized? To identify if an R object is a vector, I can use is.vector(x), which returns TRUE if x is a vector or False otherwise. Is there something similar for vectorized?
For example:
x <- c(1,2,3)
y <- c(3,4,5)
x+y
#[1] 4 6 8
Since, + is vectorized, it automatically adds individual elements of a vector x with individual elements of y. Otherwise, I'd have to use a for loop to achieve a similar output.
for(i in seq_along(x)){
cat(sprintf("%i ", x[i]+y[i]))
}
#4 6 8
My so far limited understanding of the term Vectorized entails automatic operation on elements which I'd otherwise have to do on individual elements of a vector one by one.
Is there a method you recommend to use to identify if an operation or a function in R is vectorized?
Thank you.