Posts

Module 3. Assignment

> set1 <- c( 10, 2, 3, 2, 4, 2, 5) > set2 <- c(20, 12, 13, 12, 14, 12, 15) > mean(set1) [1] 4 > mean(set2) [1] 14 > median(set1) [1] 3 > median(set2) [1] 13 > getmode(set1) [1] 2 > getmode(set2) [1] 12 > range(set1) [1] 2 10 > range(set2) [1] 12 20 > var(set1) [1] 8.333333 > var(set2) [1] 8.333333 > sd(set1) [1] 2.886751 > sd(set2) [1] 2.886751 > quantile(set1) 0% 25% 50% 75% 100% 2.0 2.0 3.0 4.5 10.0 > quantile(set2) 0% 25% 50% 75% 100% 12.0 12.0 13.0 14.5 20.0 > summary(set1) Min. 1st Qu. Median Mean 3rd Qu. Max. 2.0 2.0 3.0 4.0 4.5 10.0 > summary(set2) Min. 1st Qu. Median Mean 3rd Qu. Max. 12.0 12.0 13.0 14.0 14.5 20.0 Set#2's values are much larger than Set#1's. Set#1 has a lower mean, median, and mode. Both sets, however, share the same range, meaning they have the same spread or difference between the maximum and minimum values. ...

Module 2. Assignment

> assignment2<- c(6,18,14,22,27,17,22,20,22) > myMean <- function(assignment2) {return(sum(assignment2)/length(assignment2))} > myMean(assignment2) [1] 18.66667 The function of assignment2 is to hold the numbers as a container so that later on, it can be easily accessed, like in this example, when finding the mean. First, assignment2 is created to group all the data numbers as a vector that will later be used in the myMean function. To calculate the average, the function myMean uses assignment2 to add the numbers using sum(assignment2), then counts how many numbers are in assignment2 using length(assignment2). After that, the sum of assignment2 is divided by how many numbers there are in assignment2. Which then gets the mean of assignment2.