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.
- Evaluate
myMeanFunction - 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
myMeanthat correctly returns the mean ofassignment2.
Submission Checklist
- Downloaded and reviewed the import instructions.
- Blog post with test results, explanation, and corrected function code.
- GitHub repo updated with the blog link and corrected
myMeanfunction.
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
Post a Comment