Module #2 Assignment

Evaluating A Function 

VaShay M. Carpenter

Objectives

  • Learn how to import data into RStudio.
  • Review foundational R programming concepts and GitHub workflows.
  • Practice function debugging and evaluation in R.

  1. Evaluate myMean Function
    • Use the vector:
      assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22)
    • Consider this function:
      myMean <- function(assignment2) {
        return(sum(assignment) / length(someData))
      }
    • In RStudio, run myMean(assignment2) and record the output or error.
    • On both your blog and GitHub repository, post:
      • The result or error message from testing myMean.

      • An explanation of why the function fails or succeeds (hint: variable names).
        A good function should take an input x, process x, and return a result like a "black box". If your function is looking for a specific name like assignment2 but that variable name isn't defined inside the function's local scope, it will break or produce unpredictable results.

      • A corrected version of myMean that correctly returns the mean of assignment2.


Submission Checklist


Disclaimer:

Generative AI is integrated into my professional workflow for drafting, structural organization, and code optimization. To avoid redundancy, this statement serves as a standing disclaimer for all entries. Generative AI has been utilized to ensure technical accuracy and to facilitate the very documentation requirements mandated by the curriculum available within the course syllabus.

Comments

Popular posts from this blog

Assignment #9: Visualization in R – Base Graphics, Lattice, and ggplot2

Module # 6 Doing math in R part 2