Perform the following steps:
- First, load the mtcars data into a DataFrame with a variable named mtcars:
> data(mtcars)
- To obtain the vector range, the range function will return the lower and upper bound of the vector:
> range(mtcars$mpg) Output: [1] 10.4 33.9
- Compute the length of the variable:
> length(mtcars$mpg) Output: [1] 32
- To obtain the mean of mpg:
> mean(mtcars$mpg) Output: [1] 20.09062
- To obtain the median of the input vector:
> median(mtcars$mpg) Output: [1] 19.2
- To obtain the standard deviation of the input vector:
> sd(mtcars$mpg) Output: [1] 6.026948
- To obtain the variance of the input vector:
> var(mtcars$mpg) Output: [1] 36.3241
- The variance can also be computed with the square of ...