Second Assignment- myMean using R
1/23/25
Today I was presented with my first homework problem involving R. I was intimidated at first, but after reading the assigned chapters in the textbook I started to get a hold of what was being asked. My approach was to first read the assignment, then to study and practice the new codes/functions in R. After I was familiar with R and Rstudio, I proceeded to start with the homework which was the following: Your assignment, evaluate the following function call myMean. The data for this function called assignment. The assignment contains the following data: 6, 18, 14, 22, 27, 17, 19, 22, 20, 22
> assignment2<- c(6,18,14,22,27,17,22,20,22)
myMean <- function(assignment2) {return(sum(assignment2)/length(assignment2))}Post the result on your blog, and describe what the function called assignment2 does?
The results are as seen:
First I defined the data by a comment and created a container for it, and named it assignment2 that holds the data values. To clarify, the function assignment2 stores data. It is the input value for every use of this function, for example to find the mean. Then I wrote 'assignment 2' to display the result value of assignment2, to double check the stored values. I did the same thing for the function, first defining it utilizing a comment. Then I created the function myMean, and assigned it the value stated in the problem.

Comments
Post a Comment