There is no excerpt because this is a protected post.

## Protected: Bonus: Data Aggregation With Tapply() Exercises

There is no excerpt because this is a protected post.

## Protected: Bonus: Improve Data Consistency With Vapply()

There is no excerpt because this is a protected post.

## Protected: Improve Data Consistency With Vapply() – Solutions

There is no excerpt because this is a protected post.

## Multivariate Apply Exercises

mapply() works with multivariate arrays, and applys a function to a set of vector or list arguments. mapply() also simplifies the output. Structure of the mapply() function: mapply(FUN, …, MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE) Answers to the exercises are available here. Exercise 1 Beginning level Required dataframe: PersonnelData <- data.frame(Representative=c(1:4), Sales=c(95,110,115,90), […]

## Multivariate Apply Solutions

Below are the solutions to these exercises on Multivariate Apply. #################### # # # Exercise 1 # # # #################### PersonnelData <- data.frame(Representative=c(1:4), Sales=c(95,110,115,90), Territory=c(1:4)) mapply(class, PersonnelData) ## Representative Sales Territory ## “integer” “numeric” “integer” #################### # # # Exercise 2 # # # #################### mapply(print, PersonnelData) ## [1] 1 2 3 4 ## [1] […]

## Optimize Data Exploration With Sapply() – Exercises

The apply() functions in R are a utilization of the Split-Apply-Combine strategy for Data Analysis, and are a faster alternative to writing loops. The sapply() function applies a function to individual values of a dataframe, and simplifies the output. Structure of the sapply() function: sapply(data, function, …) The dataframe used for these exercises: dataset1 <- […]

## Optimize Data Exploration With Sapply() – Solutions

Below are the solutions to these exercises on Optimize Data Exploration With Sapply(). #################### # # # Exercise 1 # # # #################### dataset1 <- data.frame(observationA = 16:8, observationB = c(20:19, 6:12)) sapply(dataset1, length) ## observationA observationB ## 9 9 #################### # # # Exercise 2 # # # #################### sapply(dataset1, sum) ## observationA observationB […]

## Applying Functions To Lists Exercises

The lapply() function applies a function to individual values of a list, and is a faster alternative to writing loops. Structure of the lapply() function: lapply(LIST, FUNCTION, …) The list variable used for these exercises: list1 <- list(observationA = c(1:5, 7:3), observationB=matrix(1:6, nrow=2)) Answers to the exercises are available here. Exercise 1 Using lapply(), find […]

## Applying Functions To Lists Solutions

Below are the solutions to these exercises on Applying Functions To Lists. #################### # # # Exercise 1 # # # #################### list1 <- list(observationA = c(1:5, 7:3), observationB=matrix(1:6, nrow=2)) lapply(list1, length) ## $observationA ## [1] 10 ## ## $observationB ## [1] 6 #################### # # # Exercise 2 # # # #################### lapply(list1, sum) […]