Module #2 - Importing Data and Function Evaluation in R

I was able to successfully create my vector using the provided command:  

assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22)

Then, I confirmed that it was assigned to the object "assignment2" by typing "assignment2" in the Console to show the numerical values and viewing it under the Values of the Environment tab. 

After creating and running the function:

myMean <- function(assignment2) {
  return(sum(assignment) / length(someData))
}

I encountered the error message "Error in myMean(assignment2) : object 'assignment' not found". This error message indicates that the function failed and needs revision. The variable name 'assignment' does not match the initial object 'assignment2' that was stored. I updated the function (shown below) and ran myMean(assignment2)

myMean <- function(assignment2) {
  return(sum(assignment2) / length(someData))
}

I then encountered the error message "Error in myMean(assignment2) : object 'someData' not found". This error message indicates that the function failed and still needs revision. The variable name 'someData' does not match the initial object 'assignment2' that was stored. I updated the function (shown below) and ran myMean(assignment2)

myMean <- function(assignment2) {
  return(sum(assignment2) / length(assignment2))
}

The function listed above did not result in any error codes and provided an output of "19.25" for the function myMean(assignment2).


Comments

Popular posts from this blog

Assignment #5: Matrix Algebra in R

Assignment #3: Analyzing 2016 data “Poll” Data in R

Assignment #4: Visualizing and Interpreting Hospital Patient Data