Sunday, February 25, 2024

Week 7 S3 VS S4 Objects


  1. How do you tell what OO system (S3 vs. S4) an object is associated with?                               In S3, objects are defined by the information already known by the characteristics of the object; a character or numeric are recognized in R for their attributes. S4 relies on the designation determined by a user or creator of the data. setClass() produces circumstances where the classes are harder to change and are set apart at the beginning. In addition, many features pertaining to syntax and etiquette separate these systems. For example, rather than using the argument data.frame$variable to identify a column within a data set, S4 used @ and "slot" to call variables and specific instances of data. 

  2. How do you determine the base type (like integer or list) of an object?                                   Both systems are capable of taking advantage of the class() function to determine the class type of an object. Mode is also a tool that can be used to recognize the base type of objects within R. 

  3. What is a generic function?                                                                                                      A generic function is a simple sequence of code that fulfills a command or task. The methods and route can be different however the purpose and ultimate result is a single goal. 

  4. What are the main differences between S3 and S4?                                                               S3 and S4 have two main differences as listed in the lecture: Firstly, S3 objects have classes and methods identified from the beginning, which are considered more informal and widely used. S4 objects have their classes and methods developed later and take a more formal and spatial methodology. Secondly, the language and protocols for articulating commands are different. Language and syntax provide the most visually distinct differences between the two object programming. 

  5. In your GitHub, create two examples of S3 and S4. Week 7 GitHub

Thursday, February 15, 2024

Module #6 Doing Math Part II

 Module 6 built on the previous module. This weeks lecture and reading were related to additional function of linear of algebra and the different expressions of them through the use of matrices. The assignment for this week thus focused on the generation and calculation of numbers through the application of matrices. My code for this week looked like this:

I was able to quickly apply the concepts we learned last week to determine sum/difference of the two provided matrices in step one. Step two asked to create a matrix containing four rows and columns that produced a diagonal of "4,2,1,3". I use the c() function to combine the numbers as the first argument and generated the following matrix:
I had some difficulty with the last step. As shown in the first screenshot, I had tried a few different inputs to manufacture the expected matrix, however could not find the right combination that would produce it. I looked in the online textbooks and online but the exact array that the assignment wanted w was not forthcoming. I could recognize the pattern but communicating that with R was difficult. A few of the attempts not shown were identical to a few sources online that shifted the pattern but R would ignore or fail to run these. 

Saturday, February 10, 2024

Module #5 Doing Math

 This assignment was primarily concerned with the use of matrices within R. 

The first part of this task was to create matrices that printed 100 and 1000 numbers across 10 rows, respectively. The matrix A contained 1:100 and matrix B contained 1:1000. The first step was to create two vectors. I decided to use the runif() function to create my vectors. 

The results are a randomized sequence of numbers generated to fill the vector without concern for significant figures or specific characteristics. The distribution is as such likely normal. The second task was to find the determinant of the matrices and use a few calculations to find out more about the data. This step involved multiplying the matrices by the vectors and the matrices by one another; the new matrices were used to apply the det() function and find the determinant. 
The outputs were as such:

In hindsight I think I should have put more restrictions on the randomly generated numbers. Size and digits contributed to a messy string of numbers that allowed for longer series to be printed. 



Thursday, February 1, 2024

Module 4 Programming structure in R

The first part of this assignment required the initialization of 5 variables and 10 patients. 



In addition, I chose to create a data frame to better understand the data. 
The goal of this assignment was to graphically present the data in the form of a boxplot and a histogram. 
The two graphical representations reflect the general distribution of the blood pressure reported by the patients. There are a multitude of different calculations and determinations to be make about the data, however the small sample size makes it difficult to make assertions about the trends and characteristics of the data, 












Module #10 Building your own R package

 This assignment was tricky because I have never before considered being able to create my own R-package before and considered it to be more...