Posts

Showing posts from January, 2026

myMean Error and Correction

Using the following vector and function in RStudio, I ran myMean(assignment2). assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) myMean <- function(assignment2) { return(sum(assignment) / length(someData)) }    The output was "Error in myMean(assignment2) : object 'assignment' not found".   The function fails because assignment and someData are not assigned variables. These objects do not exist, so trying to pass them to the function myMean(assignment2) results in an error. To correctly return the mean of assignment2, the myMean function needs the variable assignment2 to replace assignment and someData. Corrected version of myMean, which returns 19.25. myMean <- function(assignment2) { return(sum(assignment2) / length(assignment2)) }   

Foundational Chapters: Vectors in R

Vectors in R are typically assigned with <- and  contain elements that consist of the same mode.  Unlike in other programming languages, e ven if there is an individual element like a scalar, it is considered a one-element vector in R.  Vectors are  fundamental to data analysis in R because a ll data structures in R use vectors as their basis. Vectors are the basic foundation that is then expanded open whether it be through operations or functions. By using this vectorization, I believe it makes it easier to code. If you understand the main concepts of vectors, you can use that to understand how it is applied to the rest of your data and simplify the analysis process.

Installing R and RStudio

I had already downloaded R and RStudio for a different class in a previous semester, so I did not encounter any major issues during installation. The only thing I had to do was update my RStudio application from the 2024 version I had previously used to the new 2026 version. This process was very quick and simple. When launching the old version, it immediately prompted me to update in the console window. After pressing update, it installed the 2026 application almost immediately. I was able to run it without any problems, so I added it to my desktop and deleted the 2024 version. My system details are macOS Sequoia version 15.6.1, R version 4.5.2, and RStudio version 2026.01.0+392.