Module # 2 assignment
The image above is the compiled result of working code that was entered into RStudio.
"assignment2" is a vector with the numbers 6, 18, 14, 22, 27, 17, 22, 20, 22.
"myMean" is a function. The purpose of this function is to calculate the mean, or average, of "assignment2". It takes the sum of "assignment2", which is the total of 6, 18, 14, 22, 27, 17, 22, 20, 22. The sum of "assignment2" is 168. The function then divides the sum by the length. The "length(assignment2)" is the number of values in the vector, which is 9. "myMean" takes 168 and divides it by 9 which gives an answer of 18.66667. The "return" in the "myMean" function gives the evaluated mean as the result of the function.
Comments
Post a Comment