May 2018
Beginner to intermediate
364 pages
7h 43m
English
The objective of the plyr R package is about the split-apply-combine paradigm for R. This is quite common in data analysis: we solve a complex problem by breaking it down into small pieces, doing something to each piece, and then combining the results back together again. The following is an example borrowed from its menu with a minor modification:
library(plyr) d1<-c(rep('A', 8), rep('B', 15), rep('C', 6)) d2<-sample(c("M", "F"), size = 29, replace = TRUE) d3<-runif(n = 29, min = 18, max = 54) # dfx <- data.frame(group =d1,sex=d2,age=d3) # ddply(dfx, .(group, sex), summarize, mean = round(mean(age), 2), sd = round(sd(age), 2)) # ddply(baseball[1:100,], ~ year, nrow) ddply(baseball, .(lg), c("nrow", "ncol")) rbi<-ddply(baseball, ...Read now
Unlock full access