Module 2 Assignment LIS4273
> assignment2 <- c(6,18,14,22,27,17,22,20,22)
> myMean <- function(assignment2) {return(sum(assignment2)/length(assignment2))}
> myMean(assignment2)
[1] 18.66667
The function called assignment2 is a numeric vector in R. It contains the given data points for the function myMean to perform its sets of commands.myMean takes one argument, assignment2, and calculate the sum and length of all the elements in the vector. The function returns the result after performing each command. In the end, the result of myMean(assignment2) is 18.66667.
Comments
Post a Comment