Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make function documentation more consistent

  • Loading branch information...
commit fbd7ba1da75f36dc906d74dba6a3bd60b49770b0 1 parent eb432b6
@hadley authored
View
2  R/ply-array.r
@@ -47,8 +47,6 @@ laply <- function(.data, .fun = NULL, ..., .progress = "none", .drop = TRUE, .p
#' variables, a formula or character vector
#' @param .drop_i should combinations of variables that do not appear in the
#' input data be preserved (FALSE) or dropped (TRUE, default)
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' 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)
View
118 R/ply-mapply.r
@@ -1,31 +1,12 @@
#' Call function with arguments in array or data frame, returning a data frame.
#'
-#' Call a multi-argument function with values taken from columns of an data frame or array, and combine results into a data frame
+#' Call a multi-argument function with values taken from columns of an
+#' data frame or array, and combine results into a data frame
#'
-#' The \code{m*ply} functions are the \code{plyr} version of \code{mapply},
-#' specialised according to the type of output they produce. These functions
-#' are just a convenient wrapper around \code{a*ply} with \code{margins = 1}
-#' and \code{.fun} wrapped in \code{\link{splat}}.
-#'
-#' This function combines the result into a data frame. If there are no
-#' results, then this function will return a data frame with zero rows and
-#' columns (\code{data.frame()}).
-#'
-#'
-#' @keywords manip
-#' @param .data matrix or data frame to use as source of arguments
-#' @param .fun function to be called with varying arguments
-#' @param ... other arguments passed on to \code{.fun}
-#' @param .expand should output be 1d (expand = FALSE), with an element for
-#' 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}}
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' backend provided by foreach
-#' @return a data frame
+#' @template ply
+#' @template m-
+#' @template -d
#' @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)
@@ -41,70 +22,36 @@ mdply <- function(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none", .
#' Call function with arguments in array or data frame, returning an array.
#'
-#' Call a multi-argument function with values taken from columns of an data frame or array, and combine results into an array
-#'
-#' The \code{m*ply} functions are the \code{plyr} version of \code{mapply},
-#' specialised according to the type of output they produce. These functions
-#' are just a convenient wrapper around \code{a*ply} with \code{margins = 1}
-#' and \code{.fun} wrapped in \code{\link{splat}}.
-#'
-#' This function combines the result into an array. If there are no results,
-#' then this function will return a vector of length 0 (\code{vector()}).
-#'
+#' Call a multi-argument function with values taken from columns of an
+#' data frame or array, and combine results into an array
#'
-#' @keywords manip
-#' @param .data matrix or data frame to use as source of arguments
-#' @param .fun function to be called with varying arguments
-#' @param ... other arguments passed on to \code{.fun}
-#' @param .expand should output be 1d (expand = FALSE), with an element for
-#' 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}}
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' 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)
+#' @template ply
+#' @template m-
+#' @template -a
#' @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)
#' maply(cbind(1:5, 1:5), rnorm, n = 5)
-maply <- function(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none", .parallel = FALSE) {
+maply <- function(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none",
+ .drop = TRUE, .parallel = FALSE) {
if (is.matrix(.data) & !is.list(.data)) .data <- .matrix_to_df(.data)
f <- splat(.fun)
aaply(.data = .data, .margins = 1, .fun = f, ...,
- .expand = .expand, .progress = .progress, .parallel = .parallel)
+ .expand = .expand, .progress = .progress, .parallel = .parallel,
+ .drop = drop)
}
#' Call function with arguments in array or data frame, returning a list.
#'
-#' Call a multi-argument function with values taken from columns of an data frame or array, and combine results into a list
-#'
-#' The \code{m*ply} functions are the \code{plyr} version of \code{mapply},
-#' specialised according to the type of output they produce. These functions
-#' are just a convenient wrapper around \code{a*ply} with \code{margins = 1}
-#' and \code{.fun} wrapped in \code{\link{splat}}.
-#'
-#' This function combines the result into a list. If there are no results,
-#' then this function will return a list of length 0 (\code{list()}).
+#' Call a multi-argument function with values taken from columns of an
+#' data frame or array, and combine results into a list.
#'
-#'
-#' @keywords manip
-#' @param .data matrix or data frame to use as source of arguments
-#' @param .fun function to be called with varying arguments
-#' @param ... other arguments passed on to \code{.fun}
-#' @param .expand should output be 1d (expand = FALSE), with an element for
-#' 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}}
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' backend provided by foreach
-#' @return list of results
+#' @template ply
+#' @template m-
+#' @template -l
#' @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)
@@ -122,30 +69,13 @@ mlply <- function(.data, .fun = NULL, ..., .expand = TRUE, .progress = "none", .
#' Call function with arguments in array or data frame, discarding results.
#'
-#' Call a multi-argument function with values taken from columns of an data frame or array, and discard results
-#'
-#' The \code{m*ply} functions are the \code{plyr} version of \code{mapply},
-#' specialised according to the type of output they produce. These functions
-#' are just a convenient wrapper around \code{a*ply} with \code{margins = 1}
-#' and \code{.fun} wrapped in \code{\link{splat}}.
-#'
-#' This function combines the result into a list. If there are no results,
-#' then this function will return a list of length 0 (\code{list()}).
+#' Call a multi-argument function with values taken from columns of an
+#' data frame or array, and discard results into a list.
#'
-#' @keywords manip
-#' @param .data matrix or data frame to use as source of arguments
-#' @param .fun function to be called with varying arguments
-#' @param ... other arguments passed on to \code{.fun}
-#' @param .expand should output be 1d (expand = FALSE), with an element for
-#' 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}}
-#' @param .print automatically print each result? (default: \code{FALSE})
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' backend provided by foreach
+#' @template ply
+#' @template m-
+#' @template -_
#' @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",
.print = FALSE, .parallel = FALSE ) {
if (is.matrix(.data) & !is.list(.data)) .data <- .matrix_to_df(.data)
View
73 R/ply-null.r
@@ -2,24 +2,10 @@
#'
#' For each element of a list, apply function and discard results
#'
-#' All plyr functions use the same split-apply-combine strategy: they split the
-#' input into simpler pieces, apply \code{.fun} to each piece, and then combine
-#' the pieces into a single data structure. This function splits lists by
-#' elements and discards the output. This is useful for functions that you are
-#' calling purely for their side effects like display plots and saving output.
-#'
-#' @keywords manip
-#' @param .data list to be processed
-#' @param .fun function to apply to each piece
-#' @param ... other arguments passed on to \code{.fun}
-#' @param .progress name of the progress bar to use, see \code{\link{create_progress_bar}}
-#' @param .print automatically print each result? (default: \code{FALSE})
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' backend provided by foreach
+#' @template ply
+#' @template l-
+#' @template -_
#' @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,
.parallel = FALSE) {
if (is.character(.fun) || is.list(.fun)) .fun <- each(.fun)
@@ -52,31 +38,14 @@ l_ply <- function(.data, .fun = NULL, ..., .progress = "none", .print = FALSE,
#'
#' For each subset of a data frame, apply function and discard results
#'
-#' All plyr functions use the same split-apply-combine strategy: they split the
-#' input into simpler pieces, apply \code{.fun} to each piece, and then combine
-#' the pieces into a single data structure. This function splits data frames
-#' by variable and discards the output. This is useful for functions that you
-#' are calling purely for their side effects like display plots and saving
-#' output.
-#'
-#'
-#' @keywords manip
-#' @param .data data frame to be processed
-#' @param .variables variables to split data frame by, as quoted variables, a formula or character vector
-#' @param .fun function to apply to each piece
-#' @param ... other arguments passed on to \code{.fun}
-#' @param .progress name of the progress bar to use, see \code{\link{create_progress_bar}}
-#' @param .print automatically print each result? (default: \code{FALSE})
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' backend provided by foreach
+#' @template ply
+#' @template d-
+#' @template -_
#' @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, .parallel = FALSE) {
+ .drop = TRUE, .print = FALSE, .parallel = FALSE) {
.variables <- as.quoted(.variables)
- pieces <- splitter_d(.data, .variables)
+ pieces <- splitter_d(.data, .variables, .drop = .drop)
l_ply(.data = pieces, .fun = .fun, ...,
.progress = .progress, .print = .print, .parallel = .parallel)
@@ -86,30 +55,10 @@ d_ply <- function(.data, .variables, .fun = NULL, ..., .progress = "none",
#'
#' For each slice of an array, apply function and discard results
#'
-#' All plyr functions use the same split-apply-combine strategy: they split the
-#' input into simpler pieces, apply \code{.fun} to each piece, and then combine
-#' the pieces into a single data structure. This function splits matrices,
-#' arrays and data frames by dimensions and discards the output. This is
-#' useful for functions that you are calling purely for their side effects like
-#' display plots and saving output.
-#'
-#'
-#' @keywords manip
-#' @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
-#' @param ... other arguments passed on to \code{.fun}
-#' @param .expand if \code{.data} is a data frame, should output be 1d
-#' (expand = FALSE), with an element for 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}}
-#' @param .print automatically print each result? (default: \code{FALSE})
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' backend provided by foreach
+#' @template ply
+#' @template a-
+#' @template -_
#' @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, .parallel = FALSE) {
pieces <- splitter_a(.data, .margins, .expand)
View
8 man-roxygen/-_.r
@@ -0,0 +1,8 @@
+#' @family no output
+#' @section Output:
+#' All output is discarded. This is useful for functions that you are
+#' calling purely for their side effects like displaying plots or
+#' saving output.
+#'
+#' @return Nothing
+#' @param .print automatically print each result? (default: \code{FALSE})
View
4 man-roxygen/a-.r
@@ -1,3 +1,4 @@
+#' @family array input
#' @section Input: This function splits matrices, arrays and data frames by
#' dimensions
#'
@@ -5,10 +6,7 @@
#' @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
-#' @family array input
#' @param .expand if \code{.data} is a data frame, should output be 1d (expand
#' = FALSE), with an element for each row; or nd (expand = TRUE), with a
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' backend provided by foreach
#' dimension for each variable.
View
4 man-roxygen/d-.r
@@ -1,3 +1,4 @@
+#' @family data frame input
#' @section Input: This function splits data frames by variables.
#'
#' @param .data data frame to be processed
@@ -5,6 +6,3 @@
#' variables, a formula or character vector
#' @param .drop should combinations of variables that do not appear in the
#' input data be preserved (FALSE) or dropped (TRUE, default)
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' backend provided by foreach
-#' @family data frame input
View
7 man-roxygen/l-.r
@@ -1,7 +1,4 @@
-#' @section Input: This function splits lists by elements and combines the
-#' result into a data frame.
+#' @family list input
+#' @section Input: This function splits lists by elements.
#'
#' @param .data list to be processed
-#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
-#' backend provided by foreach
-#' @family list input
View
13 man-roxygen/m-.r
@@ -0,0 +1,13 @@
+#' @details
+#' The \code{m*ply} functions are the \code{plyr} version of \code{mapply},
+#' specialised according to the type of output they produce. These functions
+#' are just a convenient wrapper around \code{a*ply} with \code{margins = 1}
+#' and \code{.fun} wrapped in \code{\link{splat}}.
+#'
+#' @family multiple arguments input
+#' @section Input: Call a multi-argument function with values taken from
+#' columns of an data frame or array
+#'
+#' @param .data matrix or data frame to use as source of arguments
+#' @param .expand should output be 1d (expand = FALSE), with an element for
+#' each row; or nd (expand = TRUE), with a dimension for each variable.
View
2  man-roxygen/ply.r
@@ -2,6 +2,8 @@
#' @param ... other arguments passed on to \code{.fun}
#' @param .progress name of the progress bar to use, see
#' \code{\link{create_progress_bar}}
+#' @param .parallel if \code{TRUE}, apply function in parallel, using parallel
+#' backend provided by foreach
#' @keywords manip
#' @references Hadley Wickham (2011). The Split-Apply-Combine Strategy
#' for Data Analysis. Journal of Statistical Software, 40(1), 1-29.
View
48 man/a_ply.Rd
@@ -6,6 +6,16 @@
.progress = "none", .print = FALSE, .parallel = FALSE)
}
\arguments{
+ \item{.fun}{function to apply to each piece}
+
+ \item{...}{other arguments passed on to \code{.fun}}
+
+ \item{.progress}{name of the progress bar to use, see
+ \code{\link{create_progress_bar}}}
+
+ \item{.parallel}{if \code{TRUE}, apply function in
+ parallel, using parallel backend provided by foreach}
+
\item{.data}{matrix, array or data frame to be processed}
\item{.margins}{a vector giving the subscripts to split
@@ -13,42 +23,42 @@
c(1,2) by rows and columns, and so on for higher
dimensions}
- \item{.fun}{function to apply to each piece}
-
- \item{...}{other arguments passed on to \code{.fun}}
-
\item{.expand}{if \code{.data} is a data frame, should
output be 1d (expand = FALSE), with an element for each
row; or nd (expand = TRUE), with a dimension for each
variable.}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
-
\item{.print}{automatically print each result? (default:
\code{FALSE})}
-
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+}
+\value{
+ Nothing
}
\description{
For each slice of an array, apply function and discard
results
}
-\details{
- All plyr functions use the same split-apply-combine
- strategy: they split the input into simpler pieces, apply
- \code{.fun} to each piece, and then combine the pieces
- into a single data structure. This function splits
- matrices, arrays and data frames by dimensions and
- discards the output. This is useful for functions that
- you are calling purely for their side effects like
- display plots and saving output.
+\section{Input}{
+ This function splits matrices, arrays and data frames by
+ dimensions
+}
+
+\section{Output}{
+ All output is discarded. This is useful for functions
+ that you are calling purely for their side effects like
+ displaying plots or saving output.
}
\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/}.
}
+\seealso{
+ Other array input: \code{\link{aaply}},
+ \code{\link{adply}}, \code{\link{alply}}
+
+ Other no output: \code{\link{d_ply}},
+ \code{\link{l_ply}}, \code{\link{m_ply}}
+}
\keyword{manip}
View
16 man/aaply.Rd
@@ -13,6 +13,9 @@
\item{.progress}{name of the progress bar to use, see
\code{\link{create_progress_bar}}}
+ \item{.parallel}{if \code{TRUE}, apply function in
+ parallel, using parallel backend provided by foreach}
+
\item{.data}{matrix, array or data frame to be processed}
\item{.margins}{a vector giving the subscripts to split
@@ -22,11 +25,8 @@
\item{.expand}{if \code{.data} is a data frame, should
output be 1d (expand = FALSE), with an element for each
- row; or nd (expand = TRUE), with a}
-
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach
- dimension for each variable.}
+ row; or nd (expand = TRUE), with a dimension for each
+ variable.}
\item{.drop}{should extra dimensions of length 1 in the
output be dropped, simplifying the output. Defaults to
@@ -81,11 +81,11 @@ aaply(ozone, 1:2, diff)
40(1), 1-29. \url{http://www.jstatsoft.org/v40/i01/}.
}
\seealso{
- Other array input: \code{\link{adply}},
- \code{\link{alply}}
+ Other array input: \code{\link{a_ply}},
+ \code{\link{adply}}, \code{\link{alply}}
Other array output: \code{\link{daply}},
- \code{\link{laply}}
+ \code{\link{laply}}, \code{\link{maply}}
}
\keyword{manip}
View
6 man/adply.Rd
@@ -58,11 +58,11 @@
40(1), 1-29. \url{http://www.jstatsoft.org/v40/i01/}.
}
\seealso{
- Other array input: \code{\link{aaply}},
- \code{\link{alply}}
+ Other array input: \code{\link{a_ply}},
+ \code{\link{aaply}}, \code{\link{alply}}
Other data frame output: \code{\link{ddply}},
- \code{\link{ldply}}
+ \code{\link{ldply}}, \code{\link{mdply}}
}
\keyword{manip}
View
6 man/alply.Rd
@@ -56,11 +56,11 @@ alply(ozone, 3, function(x) table(round(x)))
40(1), 1-29. \url{http://www.jstatsoft.org/v40/i01/}.
}
\seealso{
- Other array input: \code{\link{aaply}},
- \code{\link{adply}}
+ Other array input: \code{\link{a_ply}},
+ \code{\link{aaply}}, \code{\link{adply}}
Other list output: \code{\link{dlply}},
- \code{\link{llply}}
+ \code{\link{llply}}, \code{\link{mlply}}
}
\keyword{manip}
View
50 man/d_ply.Rd
@@ -3,14 +3,10 @@
\title{Split data frame, apply function, and discard results.}
\usage{
d_ply(.data, .variables, .fun = NULL, ...,
- .progress = "none", .print = FALSE, .parallel = FALSE)
+ .progress = "none", .drop = TRUE, .print = FALSE,
+ .parallel = FALSE)
}
\arguments{
- \item{.data}{data frame to be processed}
-
- \item{.variables}{variables to split data frame by, as
- quoted variables, a formula or character vector}
-
\item{.fun}{function to apply to each piece}
\item{...}{other arguments passed on to \code{.fun}}
@@ -18,29 +14,49 @@
\item{.progress}{name of the progress bar to use, see
\code{\link{create_progress_bar}}}
- \item{.print}{automatically print each result? (default:
- \code{FALSE})}
-
\item{.parallel}{if \code{TRUE}, apply function in
parallel, using parallel backend provided by foreach}
+
+ \item{.data}{data frame to be processed}
+
+ \item{.variables}{variables to split data frame by, as
+ \code{\link{as.quoted}} variables, a formula or character
+ vector}
+
+ \item{.drop}{should combinations of variables that do not
+ appear in the input data be preserved (FALSE) or dropped
+ (TRUE, default)}
+
+ \item{.print}{automatically print each result? (default:
+ \code{FALSE})}
+}
+\value{
+ Nothing
}
\description{
For each subset of a data frame, apply function and
discard results
}
-\details{
- All plyr functions use the same split-apply-combine
- strategy: they split the input into simpler pieces, apply
- \code{.fun} to each piece, and then combine the pieces
- into a single data structure. This function splits data
- frames by variable and discards the output. This is
- useful for functions that you are calling purely for
- their side effects like display plots and saving output.
+\section{Input}{
+ This function splits data frames by variables.
+}
+
+\section{Output}{
+ All output is discarded. This is useful for functions
+ that you are calling purely for their side effects like
+ displaying plots or saving output.
}
\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/}.
}
+\seealso{
+ Other data frame input: \code{\link{daply}},
+ \code{\link{ddply}}, \code{\link{dlply}}
+
+ Other no output: \code{\link{a_ply}},
+ \code{\link{l_ply}}, \code{\link{m_ply}}
+}
\keyword{manip}
View
12 man/daply.Rd
@@ -14,6 +14,9 @@
\item{.progress}{name of the progress bar to use, see
\code{\link{create_progress_bar}}}
+ \item{.parallel}{if \code{TRUE}, apply function in
+ parallel, using parallel backend provided by foreach}
+
\item{.data}{data frame to be processed}
\item{.variables}{variables to split data frame by, as
@@ -23,9 +26,6 @@
not appear in the input data be preserved (FALSE) or
dropped (TRUE, default)}
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
-
\item{.drop_o}{should extra dimensions of length 1 in the
output be dropped, simplifying the output. Defaults to
\code{TRUE}}
@@ -66,10 +66,10 @@ daply(baseball, .(year), function(df) colwise(mean)(df[, 6:9]))
}
\seealso{
Other array output: \code{\link{aaply}},
- \code{\link{laply}}
+ \code{\link{laply}}, \code{\link{maply}}
- Other data frame input: \code{\link{ddply}},
- \code{\link{dlply}}
+ Other data frame input: \code{\link{d_ply}},
+ \code{\link{ddply}}, \code{\link{dlply}}
}
\keyword{manip}
View
6 man/ddply.Rd
@@ -97,11 +97,11 @@ base2 <- ddply(baseball, .(id), transform,
\code{\link{tapply}} for similar functionality in the
base package
- Other data frame input: \code{\link{daply}},
- \code{\link{dlply}}
+ Other data frame input: \code{\link{d_ply}},
+ \code{\link{daply}}, \code{\link{dlply}}
Other data frame output: \code{\link{adply}},
- \code{\link{ldply}}
+ \code{\link{ldply}}, \code{\link{mdply}}
}
\keyword{manip}
View
6 man/dlply.Rd
@@ -61,11 +61,11 @@ hist(qual)
40(1), 1-29. \url{http://www.jstatsoft.org/v40/i01/}.
}
\seealso{
- Other data frame input: \code{\link{daply}},
- \code{\link{ddply}}
+ Other data frame input: \code{\link{d_ply}},
+ \code{\link{daply}}, \code{\link{ddply}}
Other list output: \code{\link{alply}},
- \code{\link{llply}}
+ \code{\link{llply}}, \code{\link{mlply}}
}
\keyword{manip}
View
36 man/l_ply.Rd
@@ -6,8 +6,6 @@
.print = FALSE, .parallel = FALSE)
}
\arguments{
- \item{.data}{list to be processed}
-
\item{.fun}{function to apply to each piece}
\item{...}{other arguments passed on to \code{.fun}}
@@ -15,29 +13,41 @@
\item{.progress}{name of the progress bar to use, see
\code{\link{create_progress_bar}}}
- \item{.print}{automatically print each result? (default:
- \code{FALSE})}
-
\item{.parallel}{if \code{TRUE}, apply function in
parallel, using parallel backend provided by foreach}
+
+ \item{.data}{list to be processed}
+
+ \item{.print}{automatically print each result? (default:
+ \code{FALSE})}
+}
+\value{
+ Nothing
}
\description{
For each element of a list, apply function and discard
results
}
-\details{
- All plyr functions use the same split-apply-combine
- strategy: they split the input into simpler pieces, apply
- \code{.fun} to each piece, and then combine the pieces
- into a single data structure. This function splits lists
- by elements and discards the output. This is useful for
- functions that you are calling purely for their side
- effects like display plots and saving output.
+\section{Input}{
+ This function splits lists by elements.
+}
+
+\section{Output}{
+ All output is discarded. This is useful for functions
+ that you are calling purely for their side effects like
+ displaying plots or saving output.
}
\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/}.
}
+\seealso{
+ Other list input: \code{\link{laply}},
+ \code{\link{ldply}}, \code{\link{llply}}
+
+ Other no output: \code{\link{a_ply}},
+ \code{\link{d_ply}}, \code{\link{m_ply}}
+}
\keyword{manip}
View
6 man/laply.Rd
@@ -61,10 +61,10 @@ laply(seq_len(10), matrix, nrow = 2, ncol = 2)
}
\seealso{
Other array output: \code{\link{aaply}},
- \code{\link{daply}}
+ \code{\link{daply}}, \code{\link{maply}}
- Other list input: \code{\link{ldply}},
- \code{\link{llply}}
+ Other list input: \code{\link{l_ply}},
+ \code{\link{ldply}}, \code{\link{llply}}
}
\keyword{manip}
View
6 man/ldply.Rd
@@ -49,10 +49,10 @@
}
\seealso{
Other data frame output: \code{\link{adply}},
- \code{\link{ddply}}
+ \code{\link{ddply}}, \code{\link{mdply}}
- Other list input: \code{\link{laply}},
- \code{\link{llply}}
+ Other list input: \code{\link{l_ply}},
+ \code{\link{laply}}, \code{\link{llply}}
}
\keyword{manip}
View
6 man/llply.Rd
@@ -63,11 +63,11 @@ llply(x, quantile, probs = 1:3/4)
40(1), 1-29. \url{http://www.jstatsoft.org/v40/i01/}.
}
\seealso{
- Other list input: \code{\link{laply}},
- \code{\link{ldply}}
+ Other list input: \code{\link{l_ply}},
+ \code{\link{laply}}, \code{\link{ldply}}
Other list output: \code{\link{alply}},
- \code{\link{dlply}}
+ \code{\link{dlply}}, \code{\link{mlply}}
}
\keyword{manip}
View
43 man/m_ply.Rd
@@ -6,29 +6,33 @@
.progress = "none", .print = FALSE, .parallel = FALSE)
}
\arguments{
- \item{.data}{matrix or data frame to use as source of
- arguments}
-
- \item{.fun}{function to be called with varying arguments}
+ \item{.fun}{function to apply to each piece}
\item{...}{other arguments passed on to \code{.fun}}
+ \item{.progress}{name of the progress bar to use, see
+ \code{\link{create_progress_bar}}}
+
+ \item{.parallel}{if \code{TRUE}, apply function in
+ parallel, using parallel backend provided by foreach}
+
+ \item{.data}{matrix or data frame to use as source of
+ arguments}
+
\item{.expand}{should output be 1d (expand = FALSE), with
an element for each row; or nd (expand = TRUE), with a
dimension for each variable.}
- \item{.progress}{name of the progress bar to use, see
- \code{\link{create_progress_bar}}}
-
\item{.print}{automatically print each result? (default:
\code{FALSE})}
-
- \item{.parallel}{if \code{TRUE}, apply function in
- parallel, using parallel backend provided by foreach}
+}
+\value{
+ Nothing
}
\description{
Call a multi-argument function with values taken from
columns of an data frame or array, and discard results
+ into a list.
}
\details{
The \code{m*ply} functions are the \code{plyr} version of
@@ -36,15 +40,28 @@
output they produce. These functions are just a
convenient wrapper around \code{a*ply} with \code{margins
= 1} and \code{.fun} wrapped in \code{\link{splat}}.
+}
+\section{Input}{
+ Call a multi-argument function with values taken from
+ columns of an data frame or array
+}
- This function combines the result into a list. If there
- are no results, then this function will return a list of
- length 0 (\code{list()}).
+\section{Output}{
+ All output is discarded. This is useful for functions
+ that you are calling purely for their side effects like
+ displaying plots or saving output.
}
\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/}.
}
+\seealso{
+ Other multiple arguments input: \code{\link{maply}},
+ \code{\link{mdply}}, \code{\link{mlply}}
+
+ Other no output: \code{\link{a_ply}},
+ \code{\link{d_ply}}, \code{\link{l_ply}}
+}
\keyword{manip}
View
38 man/maply.Rd
@@ -3,25 +3,29 @@
\title{Call function with arguments in array or data frame, returning an array.}
\usage{
maply(.data, .fun = NULL, ..., .expand = TRUE,
- .progress = "none", .parallel = FALSE)
+ .progress = "none", .drop = TRUE, .parallel = FALSE)
}
\arguments{
- \item{.data}{matrix or data frame to use as source of
- arguments}
-
- \item{.fun}{function to be called with varying arguments}
+ \item{.fun}{function to apply to each piece}
\item{...}{other arguments passed on to \code{.fun}}
- \item{.expand}{should output be 1d (expand = FALSE), with
- an element for each row; or nd (expand = TRUE), with a
- dimension for each variable.}
-
\item{.progress}{name of the progress bar to use, see
\code{\link{create_progress_bar}}}
\item{.parallel}{if \code{TRUE}, apply function in
parallel, using parallel backend provided by foreach}
+
+ \item{.data}{matrix or data frame to use as source of
+ arguments}
+
+ \item{.expand}{should output be 1d (expand = FALSE), with
+ an element for each row; or nd (expand = TRUE), with a
+ dimension for each variable.}
+
+ \item{.drop}{should extra dimensions of length 1 in the
+ output be dropped, simplifying the output. Defaults to
+ \code{TRUE}}
}
\value{
if results are atomic with same type and dimensionality,
@@ -39,9 +43,14 @@
output they produce. These functions are just a
convenient wrapper around \code{a*ply} with \code{margins
= 1} and \code{.fun} wrapped in \code{\link{splat}}.
+}
+\section{Input}{
+ Call a multi-argument function with values taken from
+ columns of an data frame or array
+}
- This function combines the result into an array. If
- there are no results, then this function will return a
+\section{Output}{
+ If there are no results, then this function will return a
vector of length 0 (\code{vector()}).
}
\examples{
@@ -54,5 +63,12 @@ maply(cbind(1:5, 1:5), rnorm, n = 5)
for Data Analysis. Journal of Statistical Software,
40(1), 1-29. \url{http://www.jstatsoft.org/v40/i01/}.
}
+\seealso{
+ Other array output: \code{\link{aaply}},
+ \code{\link{daply}}, \code{\link{laply}}
+
+ Other multiple arguments input: \code{\link{m_ply}},
+ \code{\link{mdply}}, \code{\link{mlply}}
+}
\keyword{manip}
View
41 man/mdply.Rd
@@ -6,25 +6,25 @@
.progress = "none", .parallel = FALSE)
}
\arguments{
- \item{.data}{matrix or data frame to use as source of
- arguments}
-
- \item{.fun}{function to be called with varying arguments}
+ \item{.fun}{function to apply to each piece}
\item{...}{other arguments passed on to \code{.fun}}
- \item{.expand}{should output be 1d (expand = FALSE), with
- an element for each row; or nd (expand = TRUE), with a
- dimension for each variable.}
-
\item{.progress}{name of the progress bar to use, see
\code{\link{create_progress_bar}}}
\item{.parallel}{if \code{TRUE}, apply function in
parallel, using parallel backend provided by foreach}
+
+ \item{.data}{matrix or data frame to use as source of
+ arguments}
+
+ \item{.expand}{should output be 1d (expand = FALSE), with
+ an element for each row; or nd (expand = TRUE), with a
+ dimension for each variable.}
}
\value{
- a data frame
+ A data frame, as described in the output section.
}
\description{
Call a multi-argument function with values taken from
@@ -37,9 +37,21 @@
output they produce. These functions are just a
convenient wrapper around \code{a*ply} with \code{margins
= 1} and \code{.fun} wrapped in \code{\link{splat}}.
+}
+\section{Input}{
+ Call a multi-argument function with values taken from
+ columns of an data frame or array
+}
+
+\section{Output}{
+ The most unambiguous behaviour is achieved when
+ \code{.fun} returns a data frame - in that case pieces
+ will be combined with \code{\link{rbind.fill}}. If
+ \code{.fun} returns an atomic vector of fixed length, it
+ will be \code{rbind}ed together and converted to a data
+ frame. Any other values will result in an error.
- This function combines the result into a data frame. If
- there are no results, then this function will return a
+ If there are no results, then this function will return a
data frame with zero rows and columns
(\code{data.frame()}).
}
@@ -54,5 +66,12 @@ mdply(cbind(mean = 1:5, sd = 1:5), as.data.frame(rnorm), n = 5)
for Data Analysis. Journal of Statistical Software,
40(1), 1-29. \url{http://www.jstatsoft.org/v40/i01/}.
}
+\seealso{
+ Other data frame output: \code{\link{adply}},
+ \code{\link{ddply}}, \code{\link{ldply}}
+
+ Other multiple arguments input: \code{\link{m_ply}},
+ \code{\link{maply}}, \code{\link{mlply}}
+}
\keyword{manip}
View
36 man/mlply.Rd
@@ -6,22 +6,22 @@
.progress = "none", .parallel = FALSE)
}
\arguments{
- \item{.data}{matrix or data frame to use as source of
- arguments}
-
- \item{.fun}{function to be called with varying arguments}
+ \item{.fun}{function to apply to each piece}
\item{...}{other arguments passed on to \code{.fun}}
- \item{.expand}{should output be 1d (expand = FALSE), with
- an element for each row; or nd (expand = TRUE), with a
- dimension for each variable.}
-
\item{.progress}{name of the progress bar to use, see
\code{\link{create_progress_bar}}}
\item{.parallel}{if \code{TRUE}, apply function in
parallel, using parallel backend provided by foreach}
+
+ \item{.data}{matrix or data frame to use as source of
+ arguments}
+
+ \item{.expand}{should output be 1d (expand = FALSE), with
+ an element for each row; or nd (expand = TRUE), with a
+ dimension for each variable.}
}
\value{
list of results
@@ -29,7 +29,7 @@
\description{
Call a multi-argument function with values taken from
columns of an data frame or array, and combine results
- into a list
+ into a list.
}
\details{
The \code{m*ply} functions are the \code{plyr} version of
@@ -37,10 +37,15 @@
output they produce. These functions are just a
convenient wrapper around \code{a*ply} with \code{margins
= 1} and \code{.fun} wrapped in \code{\link{splat}}.
+}
+\section{Input}{
+ Call a multi-argument function with values taken from
+ columns of an data frame or array
+}
- This function combines the result into a list. If there
- are no results, then this function will return a list of
- length 0 (\code{list()}).
+\section{Output}{
+ If there are no results, then this function will return a
+ list of length 0 (\code{list()}).
}
\examples{
mlply(cbind(1:4, 4:1), rep)
@@ -55,5 +60,12 @@ mlply(cbind(1:4, by = 4:1), seq, to = 20)
for Data Analysis. Journal of Statistical Software,
40(1), 1-29. \url{http://www.jstatsoft.org/v40/i01/}.
}
+\seealso{
+ Other list output: \code{\link{alply}},
+ \code{\link{dlply}}, \code{\link{llply}}
+
+ Other multiple arguments input: \code{\link{m_ply}},
+ \code{\link{maply}}, \code{\link{mdply}}
+}
\keyword{manip}
Please sign in to comment.
Something went wrong with that request. Please try again.