Don't wanna be here? Send us removal request.
Text
Module 12 Assignment
R Markdown has been a great tool for creating reports that integrate code, analysis, and results. The ability to combine narrative and computational output in a single document is invaluable for reproducible research and dynamic reporting. While there is a learning curve, the flexibility it offers for different types of output and its seamless integration with R code makes it a powerful choice for data scientists and researchers.
0 notes
Text
Module 11 Assignment
tukey_multiple <- function(x) { outliers <- array(TRUE,dim=dim(x)) for (j in 1:ncol(x)) { outliers[,j] <- outliers[,j] && tukey.outlier(x[,j]) } outlier.vec <- vector(length=nrow(x)) for (i in 1:nrow(x)) { outlier.vec[i] <- all(outliers[i,]) } return(outlier.vec) }
After looking at this code and trying to find the bug, that there was the use of the && operator. I would want to use & instead of && because & is the element-wise logical operator that works with vectors and matrices, while && is for scalar logical comparisons.
tukey_multiple <- function(x) { outliers <- array(TRUE,dim=dim(x)) for (j in 1:ncol(x)) { outliers[,j] <- outliers[,j] & tukey.outlier(x[,j]) } outlier.vec <- vector(length=nrow(x)) for (i in 1:nrow(x)) { outlier.vec[i] <- all(outliers[i,]) } return(outlier.vec) }
0 notes
Text
Module 10 Assignment
"Package: EZClean Title: It simplifies the data cleaning process, making it more accessible and efficient for data scientists and analysts Version: 0.1 Authors@R: Anthony Galluzzo [email protected] [aut, cre] Description: EZClean is an R package designed to simplify the data cleaning process, making it more accessible and efficient for data analysts and scientists. With a suite of intuitive functions, EZClean helps users prepare their datasets for analysis by addressing common issues such as missing values, duplicate entries, inconsistent formatting, and outlier detection. Depends: R (>= 4.4.1) License: CC0 LazyData: true"
I wanted to create this package because I do a lot of data manipulation and am constantly using datasets for assignments. I thought if I made a package that already had functions ready to use and just insert a dataset, it would make it to where I was spending less time on it and focus more on the task at hand.
0 notes
Text
Module 9 Assignment
library(ggplot2) library(RColorBrewer) smoke <- read.csv("SmokeBan.csv")
ggplot(smoke) + geom_bar(aes(x = smoker, fill = gender)) + labs(title = "Male and Female Smokers in the Workplace", x = "Do they Smoke?", y = "Count of People") + facet_grid(.~gender)
ggplot(smoke) + geom_bar(aes(smoker, fill = smoker)) + labs(title = "Smokers vs Non-Smokers in the WorkPlace", x = "Non-Smokers and Smokers" ) + scale_fill_brewer(palette = "Set2")
ggplot(smoke) + geom_bar(aes(smoker, fill = smoker)) + labs(title = "Smokers vs Non-Smokers in the WorkPlace Compared by Education", x = "Non-Smokers and Smokers" ) + scale_fill_brewer(palette = "Set3") + facet_grid(.~education)
I created this graph because I wanted to compare the smokers and non smokers in the workplace biased of their gender. These results show that not only is there more females in this data set, that there is also more female smokers than male smokers.
I created this visualization because I wanted to look at the overall smokers and nonsmokers in the work place. This graph shows that there is an overwhelming of nonsmokers compared to smokers in the workplace.
I created this visualization because I wanted to look at the smokers and nonsmokers in the workplace and compare it between the education levels. Looking at this graph, you can tell that the high school drop outs had a higher ratio of smokers compared to nonsmokers.
0 notes
Text
Module 8 Assignment
install.packages("pryr") install.packages("plyr") library(data.table) library(plyr) library(pryr) Student_assignment_6 <- read.table("Assignment 6 Dataset.txt", header = T, sep = ",") Student_assignment_6 StudentAverage <- ddply(Student_assignment_6, "Sex", summarise, Grade.Average = mean(Grade, na.rm = TRUE)) write.table(StudentAverage, "Students_Gendered_Mean.txt", row.names = FALSE) i_students <- subset(Student_assignment_6, grepl("i", Name, ignore.case = TRUE)) write.csv(i_students, "Students_With_i.csv", row.names = FALSE)
0 notes
Text
Module 7 Assignment
When dealing with trying to find out whether an object is an S3 or an S4, you can use the class function. If the object is an S3 it will return with predefined classes like data.frame. If the object is an S4 class it will return the name of the custom class that was created like "mycustomclass".
When trying to determine the base types of objects in R, you can use the typeof function to determine if it is an integer, list. ect. This can look like typeof(mtcars) which returns "list".
Generic functions are functions in R that behave differently depending on the class of the object that is being passed through it. These functions use a dispatch system for the methods to call the right method depending on the object class.
When talking about the the main differences between the an S3 object and an S4 object, one of the big differences is the complexity of the object. S3 objects assigns the class using an attribute and an S4 object require specific class definitions and requires the atribute to be defined.
0 notes
Text
Module 6 Assignment
For the first part of the assignment, I used code to create the two matrixes. Once I did this, I added and subtracted them.
A <- matrix(c(2, 0, 1, 3), ncol = 2) B <- matrix(c(5, 2, 4, -1), ncol = 2)
result1 <- A + B print(result1)
result2 <- A - B print(result2)
For the second part of the assignment I created a matrix with the specific values of 4,1,2,3 in a diagonal line
Lastly, I created the matrix that was provided in the assignment
0 notes
Text
Module 5 Assignment
Code:
A <- matrix(1:100, nrow=10) B <- matrix(1:1000, nrow=10) det_A <- det(A) det_B <- det(B) if (det_A != 0) { inv_A <- solve(A) } else { inv_A <- "Matrix A is not invertible." }
Output:
A <- matrix(1:100, nrow=10) B <- matrix(1:1000, nrow=10) det_A <- det(A) det_B <- det(B) Error in determinant.matrix(x, logarithm = TRUE, ...) : 'x' must be a square matrix if (det_A != 0) { + inv_A <- solve(A) + } else { + inv_A <- "Matrix A is not invertible." + }
inv_A [1] "Matrix A is not invertible."
Results:
When trying to find the determinant of both A and B, I found that A gave me a value of zero and since B is not a square matrix it couldn't give me a value for its determinant. When looking at the inverses for A and B, inverses only exists if the determinant is a non-zero/non-singular value, so there would be no inverse of A. Also, since we couldn't get the determinant of matrix B, we also cannot get the inverse of B.
0 notes
Text
Module 4 Assignment
Freq <- c(0.6,0.3,0.4,0.4,0.2,0.6,0.3,0.4,0.9,0.2) bloodp <- c(103,87,32,42,59,109,78,205,135,179) first <- c(1,1,1,1,0,0,0,0,1,1) second <- c(0,0,1,1,0,0,1,1,1,1) finaldecison <- c(0,1,0,1,0,1,0,1,1,1) HealthDF <- data.frame(Freq, bloodp, first, second, finaldecison) boxplot(bloodp)
hist(finaldecison)
When looking at the different patients blood pressure and the different MD that resulted from the blood pressure, there are some thing that can be assumed. Most of the time when the patient had too have of blood pressure, it would result into them having a high value for needing medical assistance.
0 notes
Text
Module 3 Assignment
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) DataFrame<- data.frame(Name, ABC_political_poll_results, CBS_political_poll_results)
When I use the function data.frame() and combined the different vectors together and made them into one data set.
0 notes
Text
Module 2 Assignment
assignment2 <- c(16, 18, 14, 22, 27, 17, 19, 17, 17, 22, 20, 22) myMean <- function(assignment2) { return(sum(assignment2)/length(assignment2)) } myMean(assignment2)
This function works by taking the sum of the numbers in the vector assignment 2 and dividing it by the number of observations in the same vector.
0 notes