Publications by John Akwei

Reshape 2 Exercises

26.08.2016

The Reshape 2 package is based on differentiating between identification variables, and measurement variables. The functions of the Reshape 2 package then “melt” datasets from wide to long format, and “cast” datasets from long to wide format. Required package: library(reshape2) Answers to the exercises are available here. Exercise 1 Set a...

2278 sym 2 img

Efficient Processing With Apply() Exercises

08.09.2016

The apply() function is an alternative to writing loops, via applying a function to columns, rows, or individual values of an array or matrix. The structure of the apply() function is: apply(X, MARGIN, FUN, ...) The matrix variable used for the exercises is: dataset1 <- cbind(observationA = 16:8, observationB = c(20:19, 6:12)) Answers to the exer...

1513 sym 2 img

Applying Functions To Lists Exercises

19.09.2016

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. ...

1438 sym 2 img

Optimize Data Exploration With Sapply() – Exercises

14.10.2016

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 exe...

1572 sym 2 img

Multivariate Apply Exercises

17.01.2017

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...

2753 sym 4 img