Assignment 2 LIS4273
This assignment featured a relatively simple R function that does a few things in succession: Declares a data set, Declares a function that manipulates or points out a certain trend in the data (in this case we are taking a statistical mean), and finally, declares a result variable to the function and prints the resultant mean. My code is as follows
#Declare data set and define as assignment2
assignment2 <- c(6,18,14,22,27,17,22,20,22)
#Write function for the data set, which involves taking the mean of the data set
myMean <- function(assignment2) {return(sum(assignment2)/length(assignment2))}
# Declare result variable to be presented as the mean of assignment2 (line 6) Resultant Mean of the assignment2 data set (line 8) using the print function on the newly defined 'result.mean' variable
result.myMean <- mean(assignment2)
#Result
print(result.myMean)
[1] 18.66666666667
My resultant mean for this data set was 18.66666666667
Comments
Post a Comment