Module # 2 assignment
Module # 2 assignment
Review Chapter # 1 - Dalgaard's Introductory Statistics with R and Matloff - The Art of R programming Chapter 1-3
Evaluate the following function call myMean. The data for this function called assignment. The assignment contains the following data: 6, 18, 14, 22, 27, 17, 19, 22, 20, 22
> assignment2<- c(6,18,14,22,27,17,22,20,22)
myMean <- function(assignment2) {return(sum(assignment2)/length(assignment2))}# Assign data to a vector
assignment2 <- c(6, 18, 14, 22, 27, 17, 19, 22, 20, 22)
# Calculate the mean
myMean <- function(assignment2) {
return(sum(assignment2) / length(assignment2))
}
# Call the function and store the result
result <- myMean(assignment2)
# Print the result
print(result)
[1] 18.7
assignment2 is a vector having a set of numbers (6, 18, 14, 22, 27, 17, 19, 22, 20, 22). It provides the data for calculating the average using the myMean function.
Comments
Post a Comment