Posts

Showing posts from October, 2024

R Visualization

Image
Daniel Tafmizi Dr. Friedman Lis 4370 Module 9 Github:  daniel.R/Work.R/LIS4370Rprog/wineClusterViz.R at main · DanielDataGit/daniel.R     I did some clustering analysis with the wine dataset that includes Country, alcohol as liters of wine, deaths per 100,000, heart disease per 100,000, and liver disease per 100,000. Some correlations are prevalent. Unsurprisingly, heart disease and death are positively correlated. Alcohol and liver disease have a positive correlation. Interestingly, heart and alcohol have a negative correlation.  I chose to use k-means as opposed to knn because of the small dataset. I think the algorithm did a great job of creating clusters. I found that three clusters resulted in the most uniformity.  It is interesting to see where each country ends up on the map. I thought this was a really cool visualization. It incorporates a dendrogram into the heatmap, showing us the clusters in a different style. This shows us that there are 5 cluster hi...

Mod 8 Input/Output

Daniel Tafmizi Dr. Friedman Lis 4370 Module 8 Github:  daniel.R/Work.R/LIS4370Rprog/Mod8input_output.R at main · DanielDataGit/daniel.R (github.com) After looking at the step-by-step solutions I see I have misunderstood the first prompt. I used group_by to summarize by sex and give the mean age and grade. The second command I used what was listed to extract [iI] names. The subset with grepl worked perfectly. It kept only names with the letter [iI] in it. I find the syntax a little weird. Using "[iI]" is not what I would expect. I was thinking it would be something like c("i", "I") or by using the | operator. Step 1: Sex Age Grade 1 Female 21.375 86.9375 2 Male 21.250 80.2500 Step 2: Name Age Sex Grade 3 Lauri 21 Female 90 4 Leonie 21 Female 91 6 Mikaela 20 Female 69 8 Aiko 24 Female 97 9 Tiffaney 21 Female 78 10 Corina 23 Female 81 11 Petronila 23 Female 98 12 Alecia 20 Female 87 13 ...

Mod 7 OOP

Daniel Tafmizi Dr. Friedman Lis 4370 Module 7 1. How do you tell what OO system (S3 vs. S4) an object is associated with? Using the function isS4() or isS3() on the object name will tell you which OO system the object was designed under.  2.  How do you determine the base type (like integer or list) of an object? There are a few useful functions for understanding the storage types of an object. typeof() for storage type, class() for structure type, mode() for data type. 3.What is a generic function? A  function that can be applied to different data and class types. A generic function will have many methods for differing data and class types and call them as needed.  4. What are the main differences between S3 and S4? Many differences lie in how operations are called in either class. These differences arise from the fact that S4 objects require explicit class, structure, and inheritance definitions, while S3 do not. I like S4 objects because they remind of classes in ...

Mod 6 matrices pt. 2

Daniel Tafmizi Dr. Friedman Lis 4370 Module 6 Github:  daniel.R/Work.R/LIS4370Rprog/math2.R at main · DanielDataGit/daniel.R (github.com) > # 1) > > A = matrix(c(2,0,1,3), ncol = 2 ) > > B = matrix(c(5,2,4,-1), ncol = 2 ) > > A + B [,1] [,2] [1,] 7 5 [2,] 2 2 > > A - B [,1] [,2] [1,] -3 -3 [2,] -2 4 > > # 2) > > diag(c(4,1,2,3)) [,1] [,2] [,3] [,4] [1,] 4 0 0 0 [2,] 0 1 0 0 [3,] 0 0 2 0 [4,] 0 0 0 3 > > # 3) > > x = diag(3,5) > > x[1, 2:5] = 1 > > x[2:5, 1] = 2 > > x [,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