Posts

Module 7: Object Oriented Programming

Image
This week we will be exploring object oriented programming (OOP).  GitHub Link:  https://github.com/Ant-nguyen/Intro_r_2021/blob/main/Module7.R Our assignment this week is to obtain any type of data and then try to determine what generic functions can be assigned to the data set. Then see how we can utilize S3 and S4 class structures and OOP paradigms in the data. This week I decided to challenge myself a bit and use a slightly unconventional type of data, a sequence of genomic data. The goal being to try to utilize OOP methods when tackling a sequence of DNA.  For those who are unfamiliar with DNA transcription I will be covering some of the basics through out but the following video is a simple to understand explanation of some of the concepts I will be dealing with: Link to DNA data:  https://www.ncbi.nlm.nih.gov/nuccore/JX262162 Raw genomic sequence:  https://www.ncbi.nlm.nih.gov/nuccore/JX262162.1?report=fasta Let us begin First let me begin by explaining w...

Module 6: Doing math with R. Part 2

Hello this week we will be continuing our exploration of different mathematical functions we can do using R. Github link:  https://github.com/Ant-nguyen/Intro_r_2021/blob/main/Module%206.R Our assignment this time are the following tasks : 1. Consider A=matrix(c(2,0,1,3), ncol=2) and B=matrix(c(5,2,4,-1), ncol=2). a) Find A + B b) Find A - B 2. Using the diag() function to build a matrix of size 4 with the following values in the diagonal 4,1,2,3. 3. Generate the following matrix: ##      [,1] [,2] [,3] [,4] [,5]      [1,]  3    1     1     1    1      [2,]  2    3     0     0    0      [3,]  2    0     3     0    0      [4,]  2    0     0     3    0      [5,]  2  ...

Module 5: Doing math with R. Part 1

This week's assignment we will focus on matrices and the linear algebra we can do using R. We are given two matrices specifications: A=matrix(1:100, nrow=10) B=matrix(1:1000, nrow=10) And told to find an inverse of a matrix and determinant of a matrix using these values. The goal here is starting with these values, we will manipulate these in order for us to attain an inverse matrix and a determinant. Github link : https://github.com/Ant-nguyen/Intro_r_2021/blob/main/Module%205.R Let us begin First we must create matrices A and B in R. To do this we simply assign the matrices to the corresponding variables: A <- matrix(1:100, nrow=10) B <- matrix(1:1000, nrow=10) We get the following matrices: A <- matrix(1:100, nrow = 10) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 11 21 31 41 51 61 71 81 91 [2,] 2 12 22 32 42 52 62 72 82 92 [3,] 3 13 23 33 43 53 63 73 83 93 [4,] 4 14 24 34 ...

Programming structure assignment (Doctors diagnosis and BP)

Image
This week's assignment we are given a mock up of patients' frequency visiting the hospital(Freq), their blood pressure(BP), and three different doctors rating on the patients condition. The first doctor is a general doctor and is simply stating "bad" or "good", and the other two doctors are external doctors rating the patients condition based on decision regarding immediate care( low or high). We are told to give these rating numerical representation based on either 1 or 0. (bad = 0, good =1) and low = 0 ,high = 1) Variables are : Freq, BP, "First", "second", "final". 1.    "0.6","103","bad","low","low” 2.     "0.3","87","bad","low","high” 3.     "0.4","32","bad","high","low” 4.      "0.4","42","bad","high","high" 5.     "0.2","59...

Intro to data.frame

Image
This week we will begin to familiarize ourselves with Data Frames. We are given mock data representing the polls for the 2016 U.S Presidential Election by ABC and CBS. Here are the information given to us exactly as it was presented: > Name <- c("Jeb", “Donald”, "Ted”, “Marco” “Carly”, “Hillary”, “Berine”) > ABC political poll results <- c(4, 62,51, 21, 2, 14, 15) > CBS political poll results <- c(12, 75, 43, 19, 1, 21, 19) Our goal here is to take what we have learned about Data Frames and try to organize our data in R with what we've learned so far. Github link:  https://github.com/Ant-nguyen/Intro_r_2021/blob/main/Module%203.R Let's begin! First we assign the different candidates to vector named 'Name'.* >Name <-c("Jeb","Donald","Ted","Marco","Carly", "Hillary", "Bernie") *Note: That in order to do this we couldn't simply copy and paste the line that was p...

myMean assignment

Image
For our first R assignment we will be working with how user created functions work by testing a user created function myMean. Here is a GitHub link of all the testing I did based on the history of commands I ran on RStudio:   https://github.com/Ant-nguyen/Intro_r_2021/blob/main/myMean/.Rhistory Let's begin! We are given a set of data and a user created function: assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) myMean <- function(assignment2) { return(sum(assignment)/length(someData)) } To test this we open up RStudio and copy and paste the provided data and function. So far so good, we do not get any error and RStudio assigns the argument and function accordingly: (Line 1 &2 in the Rhistory on GitHub) Now we test our function (Line 3). We get an error:  Error in myMean(assignment2 = assignment2) :    object 'assignment' not found Looking at our function it seems that R does not know what assignment is since nothing was assigned to it! So we ...

GitHub repository

Here is my GitHub repository for my R-2021 class: https://github.com/Ant-nguyen/Intro_r_2021 Here I will upload projects and assignments I'm working on. Excited to learn R! -Ant