LIS 4273 Module #2 Assignment

I received an assignment that stated I needed to evaluate the following function call myMean. The data for this function is called assignment. The assignment contains the following data: 6181422271719222022

R Studio Script:

> assignment2<- c(6,18,14,22,27,17,19,22,20,22)
> myMean <- function(assignment2) {return(sum(assignment2)/length(assignment2))}
> myMean(assignment2)
[1] 18.7


3. Describe what the function called assignment2 does?
- assignment2 is a vector that contains the numbers (6,18,14,22,27,17,19,22,20,22)This vector represents the dataset on which you want to perform the mean calculation. 

- myMean is a custom function that calculates the mean of the values in the assignment2 vector. 

- sum(assignment2) calculates the total sum of the values in assignment2

- length(assignment2) returns the number of elements in the vector (in this case, 10). 

- The function divides the sum by the number of elements to compute the average which is 18.7.


Comments

Popular posts from this blog

LIS 4273 Module #5 Assignment