Posts

Showing posts from September, 2023

Week 6: Doing Math P2

Image
Hi everyone! This week we learned more mathematical operations to use in matrices. A new function I learned is diag() which represents the number you choose in the top left to bottom right diagonal spots of the matrix. Similar to a data frame, you can select cells in a matrix using square brackets []. I utilized this to define numbers for spots in the matrix. 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 0 0 0 3 Hint: You can use the command  diag()  to build it. Check this out in GitHub ! - Ramya's POV

Week 5: Doing Math

Image
Hi everyone! This week we learned about multiple mathematical operations used in R. For statistical analysis, we can study multiple variables either categorical or quantitative through descriptive statistics such as mean, median, mode, standard deviation, and range. Data can be visualized in histograms, bar plots, box plots, or probability  distributions for bivariate analysis.   The math functions we learned include matrix algebra. A matrix has n * m dimensions with vectors constituting each row or column. We can add two matrices by each element, multiply each element by a number, multiply two matrices by each element, create an identity matrix, or find the inverse of a matrix. An important note is if the matrix has a determinant of zero, there is no inverse for this matrix and is said to be singular. If the matrix is not a square matrix, there will be no determinant and therefore no inverse.  A determinant of a matrix is a special number of...

Week 4: Programming structures

Image
Hi everyone! This week we learned about different apply functions including lapply and other visualization techniques such as box plots, and histograms.  The lapply() function in the R Language takes a list, vector, or data frame as input and gives output in the form of a list object. The structure is lapply(x, function to apply).  Boxplots are used to visualize the spread of data and in R we can do this by using boxplot(variable1 ~ variable2) where variable  1 on the y axis is explained by variable 2 on the x axis.  Histograms represent the distribution  of numerical data. In R, we can create basic histograms using hist(variable1) where variable1 is the numerical dataset.  The following data was collected by the local hospital. This data set contains 5 variables based on observation of 8 patients. In addition to the measurements of the patients checking in to the hospital that night, this data provides the patients' histories regarding the frequency o...

Week 3: Data Frames

Image
Hi everyone! This week I learned about matrices and data frames. Matrices are collection of elements in the same data type in fixed rows and columns. An example code layout is: matrix(1:4, byrow = TRUE, nrow = 2). In this example, the numbers 1 to 4 will be organized by row in 2 rows and 2 columns.  Data frames are collection of elements that can be a variety of data types that must be in a structure with the same number of rows and columns. You can even name the rows and columns using row.names(dataframe) <- c(names) and colnames(dataframe) <- c(names). An example code layout is: data.frame(Friends = c("Mary", "Sue"), Color = c("Green", "Blue")).  For this week's assignment, I will be looking at hypothetical election results.  The data set below is based on the presidential election during 2016, where it outlined the name of the candidate, the source of the poll (ABC vs, CBS). Discuss your result in your blog. Important note, I made up...