Skip to content

Commit

Permalink
Add references to help files
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Apr 5, 2011
1 parent f28c5e7 commit bf183b1
Show file tree
Hide file tree
Showing 26 changed files with 120 additions and 0 deletions.
9 changes: 9 additions & 0 deletions R/ply-array.r
Expand Up @@ -23,6 +23,9 @@
#' backend provided by foreach
#' @return if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' laply(baseball, is.factor)
#' # cf
Expand Down Expand Up @@ -67,6 +70,9 @@ laply <- function(.data, .fun = NULL, ..., .progress = "none", .drop = TRUE, .p
#' backend provided by foreach
#' @return if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' daply(baseball, .(year), nrow)
#'
Expand Down Expand Up @@ -114,6 +120,9 @@ daply <- function(.data, .variables, .fun = NULL, ..., .progress = "none", .drop
#' backend provided by foreach
#' @return if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' dim(ozone)
#' aaply(ozone, 1, mean)
Expand Down
9 changes: 9 additions & 0 deletions R/ply-data-frame.r
Expand Up @@ -24,6 +24,9 @@
#' backend provided by foreach
#' @return a data frame
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
ldply <- function(.data, .fun = NULL, ..., .progress = "none", .parallel = FALSE) {
if (!inherits(.data, "split")) .data <- as.list(.data)
res <- llply(.data = .data, .fun = .fun, ...,
Expand Down Expand Up @@ -61,6 +64,9 @@ ldply <- function(.data, .fun = NULL, ..., .progress = "none", .parallel = FALSE
#' backend provided by foreach
#' @return a data frame
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' ddply(baseball, .(year), "nrow")
#' ddply(baseball, .(lg), c("nrow", "ncol"))
Expand Down Expand Up @@ -103,6 +109,9 @@ ddply <- function(.data, .variables, .fun = NULL, ..., .progress = "none", .drop
#' backend provided by foreach
#' @return a data frame
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
adply <- function(.data, .margins, .fun = NULL, ..., .expand = TRUE, .progress = "none", .parallel = FALSE) {
pieces <- splitter_a(.data, .margins, .expand)

Expand Down
9 changes: 9 additions & 0 deletions R/ply-list.r
Expand Up @@ -23,6 +23,9 @@
#' backend provided by foreach
#' @return list of results
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' llply(llply(mtcars, round), table)
#' llply(baseball, summary)
Expand Down Expand Up @@ -123,6 +126,9 @@ llply <- function(.data, .fun = NULL, ..., .progress = "none", .inform = FALSE,
#' backend provided by foreach
#' @return if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' linmod <- function(df) lm(rbi ~ year, data = mutate(df, year = year - min(year)))
#' models <- dlply(baseball, .(id), linmod)
Expand Down Expand Up @@ -156,6 +162,9 @@ dlply <- function(.data, .variables, .fun = NULL, ..., .progress = "none", .drop
#'
#' @keywords manip
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @param .data matrix, array or data frame to be processed
#' @param .margins a vector giving the subscripts to split up \code{data} by. 1 splits up by rows, 2 by columns and c(1,2) by rows and columns, and so on for higher dimensions
#' @param .fun function to apply to each piece
Expand Down
12 changes: 12 additions & 0 deletions R/ply-mapply.r
Expand Up @@ -23,6 +23,9 @@
#' backend provided by foreach
#' @return a data frame
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' mdply(data.frame(mean = 1:5, sd = 1:5), rnorm, n = 2)
#' mdply(expand.grid(mean = 1:5, sd = 1:5), rnorm, n = 2)
Expand Down Expand Up @@ -59,6 +62,9 @@ mdply <- function(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none", .
#' backend provided by foreach
#' @return if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' maply(cbind(mean = 1:5, sd = 1:5), rnorm, n = 5)
#' maply(expand.grid(mean = 1:5, sd = 1:5), rnorm, n = 5)
Expand Down Expand Up @@ -94,6 +100,9 @@ maply <- function(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none", .
#' backend provided by foreach
#' @return list of results
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' mlply(cbind(1:4, 4:1), rep)
#' mlply(cbind(1:4, times = 4:1), rep)
Expand Down Expand Up @@ -128,6 +137,9 @@ mlply <- function(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none", .
#' each row; or nd (expand = TRUE), with a dimension for each variable.
#' @param .progress name of the progress bar to use, see \code{\link{create_progress_bar}}
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
m_ply <- function(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none") {
if (is.matrix(.data) & !is.list(.data)) .data <- .matrix_to_df(.data)

Expand Down
9 changes: 9 additions & 0 deletions R/ply-null.r
Expand Up @@ -15,6 +15,9 @@
#' @param .progress name of the progress bar to use, see \code{\link{create_progress_bar}}
#' @param .print automatically print each result? (default: \code{FALSE})
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
l_ply <- function(.data, .fun = NULL, ..., .progress = "none", .print = FALSE) {
if (is.character(.fun)) .fun <- do.call("each", as.list(.fun))
if (!is.function(.fun)) stop(".fun is not a function.")
Expand Down Expand Up @@ -52,6 +55,9 @@ l_ply <- function(.data, .fun = NULL, ..., .progress = "none", .print = FALSE) {
#' @param .progress name of the progress bar to use, see \code{\link{create_progress_bar}}
#' @param .print automatically print each result? (default: \code{FALSE})
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
d_ply <- function(.data, .variables, .fun = NULL, ..., .progress = "none", .print = FALSE) {
.variables <- as.quoted(.variables)
pieces <- splitter_d(.data, .variables)
Expand Down Expand Up @@ -81,6 +87,9 @@ d_ply <- function(.data, .variables, .fun = NULL, ..., .progress = "none", .prin
#' @param .progress name of the progress bar to use, see \code{\link{create_progress_bar}}
#' @param .print automatically print each result? (default: \code{FALSE})
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
a_ply <- function(.data, .margins, .fun = NULL, ..., .expand = TRUE, .progress = "none", .print = FALSE) {
pieces <- splitter_a(.data, .margins, .expand)

Expand Down
12 changes: 12 additions & 0 deletions R/ply-replicate.r
Expand Up @@ -13,6 +13,9 @@
#' @param .progress name of the progress bar to use, see \code{\link{create_progress_bar}}
#' @return list of results
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' mods <- rlply(100, lm(y ~ x, data=data.frame(x=rnorm(100), y=rnorm(100))))
#' hist(laply(mods, function(x) summary(x)$r.squared))
Expand Down Expand Up @@ -53,6 +56,9 @@ rlply <- function(.n, .expr, .progress = "none") {
#' @param .progress name of the progress bar to use, see \code{\link{create_progress_bar}}
#' @return a data frame
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' rdply(20, mean(runif(100)))
#' rdply(20, each(mean, var)(runif(100)))
Expand Down Expand Up @@ -86,6 +92,9 @@ rdply <- function(.n, .expr, .progress = "none") {
#' @return if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)
#' @param .drop should extra dimensions of length 1 be dropped, simplifying the output. Defaults to \code{TRUE}
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' raply(100, mean(runif(100)))
#' raply(100, each(mean, var)(runif(100)))
Expand Down Expand Up @@ -121,6 +130,9 @@ raply <- function(.n, .expr, .progress = "none", .drop = TRUE) {
#' @param .progress name of the progress bar to use, see \code{\link{create_progress_bar}}
#' @param .print automatically print each result? (default: \code{FALSE})
#' @export
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy for
#' Data Analysis. Journal of Statistical Software, 40(1), 1-29.
#' \url{http://www.jstatsoft.org/v40/i01/}.
#' @examples
#' r_ply(10, plot(runif(50)))
#' r_ply(25, hist(runif(1000)))
Expand Down
3 changes: 3 additions & 0 deletions man/a_ply.Rd
Expand Up @@ -21,6 +21,9 @@
display plots and saving output.
}
\keyword{manip}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{matrix, array or data frame to be processed}
\item{.margins}{a vector giving the subscripts to split up \code{data} by. 1 splits up by rows, 2 by columns and c(1,2) by rows and columns, and so on for higher dimensions}
Expand Down
3 changes: 3 additions & 0 deletions man/aaply.Rd
Expand Up @@ -30,6 +30,9 @@
}
\keyword{manip}
\value{if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{matrix, array or data frame to be processed}
\item{.margins}{a vector giving the subscripts to split up \code{data} by. 1 splits up by rows, 2 by columns and c(1,2) by rows and columns, and so on for higher dimensions}
Expand Down
3 changes: 3 additions & 0 deletions man/adply.Rd
Expand Up @@ -22,6 +22,9 @@
}
\keyword{manip}
\value{a data frame}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{matrix, array or data frame to be processed}
\item{.margins}{a vector giving the subscripts to split up \code{data} by. 1 splits up by rows, 2 by columns and c(1,2) by rows and columns, and so on for higher dimensions}
Expand Down
3 changes: 3 additions & 0 deletions man/alply.Rd
Expand Up @@ -24,6 +24,9 @@
for cases where the results are not atomic.
}
\keyword{manip}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\value{list of results}
\arguments{
\item{.data}{matrix, array or data frame to be processed}
Expand Down
3 changes: 3 additions & 0 deletions man/d_ply.Rd
Expand Up @@ -20,6 +20,9 @@
their side effects like display plots and saving output.
}
\keyword{manip}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{data frame to be processed}
\item{.variables}{variables to split data frame by, as quoted variables, a formula or character vector}
Expand Down
3 changes: 3 additions & 0 deletions man/daply.Rd
Expand Up @@ -24,6 +24,9 @@
}
\keyword{manip}
\value{if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{data frame to be processed}
\item{.variables}{variables to split data frame by, as quoted variables, a formula or character vector}
Expand Down
3 changes: 3 additions & 0 deletions man/ddply.Rd
Expand Up @@ -29,6 +29,9 @@
}
\keyword{manip}
\value{a data frame}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{data frame to be processed}
\item{.variables}{variables to split data frame by, as quoted variables, a formula or character vector}
Expand Down
3 changes: 3 additions & 0 deletions man/dlply.Rd
Expand Up @@ -24,6 +24,9 @@
}
\keyword{manip}
\value{if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{data frame to be processed}
\item{.variables}{variables to split data frame by, as quoted variables, a formula or character vector}
Expand Down
3 changes: 3 additions & 0 deletions man/l_ply.Rd
Expand Up @@ -18,6 +18,9 @@
effects like display plots and saving output.
}
\keyword{manip}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{list to be processed}
\item{.fun}{function to apply to each piece}
Expand Down
3 changes: 3 additions & 0 deletions man/laply.Rd
Expand Up @@ -27,6 +27,9 @@
}
\keyword{manip}
\value{if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{input list}
\item{.fun}{function to apply to each piece}
Expand Down
3 changes: 3 additions & 0 deletions man/ldply.Rd
Expand Up @@ -28,6 +28,9 @@
}
\keyword{manip}
\value{a data frame}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{list to be processed}
\item{.fun}{function to apply to each piece}
Expand Down
3 changes: 3 additions & 0 deletions man/llply.Rd
Expand Up @@ -25,6 +25,9 @@
}
\keyword{manip}
\value{list of results}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{list to be processed}
\item{.fun}{function to apply to each piece}
Expand Down
3 changes: 3 additions & 0 deletions man/m_ply.Rd
Expand Up @@ -22,6 +22,9 @@
length 0 (\code{list()}).
}
\keyword{manip}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{matrix or data frame to use as source of arguments}
\item{.fun}{function to be called with varying arguments}
Expand Down
3 changes: 3 additions & 0 deletions man/maply.Rd
Expand Up @@ -24,6 +24,9 @@
}
\keyword{manip}
\value{if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{matrix or data frame to use as source of arguments}
\item{.fun}{function to be called with varying arguments}
Expand Down
3 changes: 3 additions & 0 deletions man/mdply.Rd
Expand Up @@ -27,6 +27,9 @@
}
\keyword{manip}
\value{a data frame}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{matrix or data frame to use as source of arguments}
\item{.fun}{function to be called with varying arguments}
Expand Down
3 changes: 3 additions & 0 deletions man/mlply.Rd
Expand Up @@ -24,6 +24,9 @@
}
\keyword{manip}
\value{list of results}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.data}{matrix or data frame to use as source of arguments}
\item{.fun}{function to be called with varying arguments}
Expand Down
3 changes: 3 additions & 0 deletions man/r_ply.Rd
Expand Up @@ -14,6 +14,9 @@
\code{\link{replicate}}, but never returns anything
}
\keyword{manip}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.n}{number of times to evaluate the expression}
\item{.expr}{expression to evaluate}
Expand Down
3 changes: 3 additions & 0 deletions man/raply.Rd
Expand Up @@ -19,6 +19,9 @@
}
\keyword{manip}
\value{if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.n}{number of times to evaluate the expression}
\item{.expr}{expression to evaluate}
Expand Down
3 changes: 3 additions & 0 deletions man/rdply.Rd
Expand Up @@ -19,6 +19,9 @@
}
\keyword{manip}
\value{a data frame}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.n}{number of times to evaluate the expression}
\item{.expr}{expression to evaluate}
Expand Down
3 changes: 3 additions & 0 deletions man/rlply.Rd
Expand Up @@ -19,6 +19,9 @@
}
\keyword{manip}
\value{list of results}
\references{Hadley Wickham (2011). The Split-Apply-Combine Strategy for
Data Analysis. Journal of Statistical Software, 40(1), 1-29.
\url{http://www.jstatsoft.org/v40/i01/}.}
\arguments{
\item{.n}{number of times to evaluate the expression}
\item{.expr}{expression to evaluate}
Expand Down

0 comments on commit bf183b1

Please sign in to comment.