Explain some of the useful functions provided by R which can perform vector operations.
Let us assign the following vectors
v <- c(12,45,100,2)
To perform sum of all the elements we can use sum() function which will add each of the elements present in a vector
sum(v)
[1] 159
To perform mean of all the elements we can use mean() function which will calculate the average of the vector
mean(v)
[1] 39.75
To perform variance of all the elements we can use var() function which will calculate the variance of all the elements present in a vector.
var(v)
[1] 1950.917
To perform standard deviation of all the elements we can use sd() function
sd(v)
[1] 44.16918
To perform maximum of all the elements we can use max() function
max(v)
[1] 100
To perform a minimum of all the elements we can use min() function
min(v)
[1] 2
To perform product of all the elements we can use prod() function
prod(v)
[1] 108000