In: Statistics and Probability
) Let X ={35, 45, 39, 41, 41, 44, 46, 48, 49, 34, 12, 50, 20, 38, 40}(a.) Insert X into R. (a.) Find the mean of X. (b.) Depict X in a boxplot. (NOTE: This question should be answered entirely using code for R.)
Given here is an X where,
(a) Now here we need to insert X into R i.e we need to create an X vector using code in R.
Now we know that to create a vector in R we use the function,
Hence to create a vector and store it in X we need to write the following code in R console,
X<- c(35, 45, 39, 41, 41, 44, 46, 48, 49, 34, 12, 50, 20, 38, 40)
And then press Enter.
To check whether the vector is really stored in X we can write,
print(X)
The output will be,
[1] 35 45 39 41 41 44 46 48 49 34 12 50 20 38 40
Hence our vector has been succesfully stored in X.
(b) Now since we have created a vector and stored it in X now we need to find the mean of X.
In R to find the mean of a vector stored in X we use a function,
Hence to find the mean of X we write the following code in R console,
mean(X)
And then press Enter.
The output is,
[1] 38.8
Hence the mean of the vector X is 38.8
(c) Now here we need to depict X in a boxplot.
That is we need to create a boxplot using X.
In R to create a boxplot we use the function,
Hence to create the boxplot of X we write the following code in R console,
boxplot(X)
And then press Enter.
The output is,
Clearly we can see that our vector contains two outliers.