The Art of Programming Assignment

 For this assignment, I created a vector in R called assignment2 using the numbers 6, 18, 14, 22, 27, 17, 22, 20, and 22. A vector in R is simply a collection of values stored together under one name, making it easy to perform calculations on the entire set.

Next, I used the custom function myMean, which works by adding all the numbers in the vector with sum(assignment) and then dividing that total by the number of elements using length(assignment). Running the function gave me a result of 18.67, which represents the average of the dataset. This shows how we can create our own function in R to calculate something as common as the mean, even though R already has a built-in mean () function.

Comments

Popular posts from this blog

Descriptive Statistics: Comparing Two Data Sets in R

Understanding Regression Models: Predicting, Analyzing, and Interpreting Data in R