Posts

Showing posts from January, 2026

Module # 2 Assignment

  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)) } assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) myMean <- function(assignment2) {   return(sum(assignment) / length(someData)) } myMean(assignment2) Error in sum(assignment) : object 'assignment' not found The function fails due to incorrect variable names inside the function body . The function argument is named assignment2 Inside the function, the variables assignment and someData are used These variables do not exist within the function or the global environment Corrected Version of myMean() myMean <- function ( assignment2 ) { sum ( assignment2 ) / length ( assignment2 ) } Testing the Corrected Function myMean ( assignment2 ) Correct Output [ 1 ] 19.25 Reflection This exercise helped reinforc...

R Programming Journal – Abdulrahman Elsayed

Image
  What is an R vector? Why vectors are fundamental to data analysis in R? An R vector is basically a list of values in R that are all the same type, like a group of numbers, words, or true/false values. Vectors are really important in R because almost everything you work with is built from them, including data frame columns and the results of calculations. Since R is designed to work with vectors all at once instead of one value at a time, it makes analyzing data faster, easier, and less complicated. Any issues you encountered during R and RStudio installation?  During the installation process, I ran into a few minor issues but nothing too serious. The main problem was that R installed correctly, but RStudio wouldn’t recognize the R version at first. When I tried to open RStudio, it gave an error saying it couldn’t find R on my system. This was a little confusing at first because I was sure R had already been installed. To fix the issue, I double-checked the installation ord...