Module #2 Assignment
In this assignment, I was given a set of numbers and named the vector assignment2. The original myMean function failed because the variable name inside the function (assignment and someData) do not match the argument assignment2. R looks for assignment is the function is called and it will calculate the sum of someData to determine the length but can't find neither variable so it gives an error. R only works when the function operates on a variable that is passed as an argument and defined within the function itself. The corrected function in the second paragraph uses the argument assignment2 consistently in both sum() and length(). This allows R to run the total of the numbers in the vector and divide by how many numbers there are. It will return the correct mean of 19.25. Basically, the error happens due to inconsistent variable names, and fixing the name ensures the function works as intended. GitHub: nbrown022/r-programming-assignments: Naomi Brown