Module #2: Calculating Vector Mean
Calculating Vector Mean
The R script creates the myMean function, which computes the average of the assignment2 vector. The sum(assignment2) code calculates the total of each component in the vector assignment2. Using the formula, length(assignment2), the vector's length, or the number of assignment2's elements, is determined. The mean is then calculated by dividing the sum of the elements by the length of the vector.
The assignment2 vector's mean value is around 18.66667.
Comments
Post a Comment