Permalink
Browse files

Documentation improvements

  • Loading branch information...
1 parent be273b8 commit b8be46daf898741e8bd5a5f277ed30620785fc4c @hadley committed Apr 12, 2009
View
1 R/helper-splat.r
@@ -6,6 +6,7 @@
#
# @arguments function to splat
# @value a function
+#
#X hp_per_cyl <- function(hp, cyl, ...) hp / cyl
#X splat(hp_per_cyl)(mtcars[1,])
#X splat(hp_per_cyl)(mtcars)
View
1 R/helper-try.r
@@ -6,6 +6,7 @@
# @argument should all error messages be suppressed?
# @value a function
# @seealso \code{\link{try_default}}
+# @keyword debugging
#X f <- function(x) if (x == 1) stop("Error!") else 1
#X \dontrun{
#X f(1)
View
2 R/indexed-array.r
@@ -3,7 +3,7 @@
#
# @arguments environment containing data frame
# @argument list of indices
-# @keywords internal
+# @keyword internal
# @alias [[.indexed_array
# @alias names.indexed_array
# @alias length.indexed_array
View
2 R/indexed-data-frame.r
@@ -3,7 +3,7 @@
#
# @arguments environment containing data frame
# @argument list of indices
-# @keywords internal
+# @keyword internal
# @alias length.indexed
# @alias names.indexed
# @alias as.list.indexed
View
2 R/ninteraction.r
@@ -1,7 +1,7 @@
# Numerical interaction
# A purely numerical interaction function that powers \code{aaply}.
#
-# @keywords internal
+# @keyword internal
ninteraction <- function(.variables, drop = FALSE) {
if (length(.variables) == 0) {
res <- structure(rep.int(1L, nrow(.variables)), n = 1L)
View
6 R/ply-array.r
@@ -10,7 +10,7 @@
# \code{laply} is very similar in spirit to \code{\link{sapply}} except that
# it will always return an array, and the output is transposed with respect
# \code{sapply} - each element of the list corresponds to a column, not a
-# row.
+# row.
#
#
# @keyword manip
@@ -20,7 +20,6 @@
# @arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
# @arguments should extra dimensions of length 1 be dropped, simplifying the output. Defaults to \code{TRUE}
# @value if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)
-#
#X laply(baseball, is.factor)
#X # cf
#X ldply(baseball, is.factor)
@@ -52,7 +51,6 @@ laply <- function(.data, .fun = NULL, ..., .progress = "none", .drop = TRUE) {
# \code{daply} with a function that operates column-wise is similar to
# \code{\link{aggregate}}.
#
-#
# @keyword manip
# @arguments data frame to be processed
# @arguments variables to split data frame by, as quoted variables, a formula or character vector
@@ -61,7 +59,6 @@ laply <- function(.data, .fun = NULL, ..., .progress = "none", .drop = TRUE) {
# @arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
# @arguments should extra dimensions of length 1 be dropped, simplifying the output. Defaults to \code{TRUE}
# @value if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)
-#
#X daply(baseball, .(year), nrow)
#X
#X # Several different ways of summarising by variables that should not be
@@ -102,7 +99,6 @@ daply <- function(.data, .variables, .fun = NULL, ..., .progress = "none", .drop
# @arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
# @arguments should extra dimensions of length 1 be dropped, simplifying the output. Defaults to \code{TRUE}
# @value if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)
-#
#X dim(ozone)
#X aaply(ozone, 1, mean)
#X aaply(ozone, 1, mean, .drop = FALSE)
View
2 R/ply-data-frame.r
@@ -52,7 +52,6 @@ ldply <- function(.data, .fun = NULL, ..., .progress = "none") {
# @arguments other arguments passed on to \code{.fun}
# @arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
# @value a data frame
-#X
#X ddply(baseball, .(year), "nrow")
#X ddply(baseball, .(lg), c("nrow", "ncol"))
#X
@@ -86,7 +85,6 @@ ddply <- function(.data, .variables, .fun = NULL, ..., .progress = "none", .drop
# frame. If there are no results, then this function will return a data frame
# with zero rows and columns (\code{data.frame()}).
#
-#
# @keyword manip
# @arguments matrix, array or data frame to be processed
# @arguments 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
View
2 R/ply-list.r
@@ -17,7 +17,6 @@
# @arguments other arguments passed on to \code{.fun}
# @arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
# @value list of results
-#
#X llply(llply(mtcars, round), table)
#X llply(baseball, summary)
#X # Examples from ?lapply
@@ -129,7 +128,6 @@ dlply <- function(.data, .variables, .fun = NULL, ..., .progress = "none", .drop
# @arguments other arguments passed on to \code{.fun}
# @arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
# @value list of results
-#
#X alply(ozone, 3, quantile)
#X alply(ozone, 3, function(x) table(round(x)))
alply <- function(.data, .margins, .fun = NULL, ..., .progress = "none") {
View
1 R/ply-mapply.r
@@ -97,7 +97,6 @@ mlply <- function(.data, .fun = NULL, ..., .progress = "none") {
# 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()}).
#
-#
# @keyword manip
# @arguments matrix or data frame to use as source of arguments
# @arguments function to be called with varying arguments
View
5 R/progress.r
@@ -21,8 +21,7 @@
#
# @arguments type of progress bar to create
# @seealso \code{\link{progress_none}}, \code{\link{progress_text}}, \code{\link{progress_tk}}, \code{\link{progress_win}}
-# @keywords asdf
-# @keywords
+# @keyword utilities
#X l_ply(1:1000, identity, .progress = "none")
#X l_ply(1:1000, identity, .progress = "tk")
#X l_ply(1:1000, identity, .progress = "text")
@@ -38,7 +37,7 @@ create_progress_bar <- function(name = "none") {
# This the default progress bar used by plyr functions. It's very simple to
# understand - it does nothing!
#
-# @keywords internal
+# @keyword internal
#X l_ply(1:100, identity, .progress = "none")
progress_none <- function() {
list(
View
4 R/rbind.r
@@ -54,6 +54,10 @@ rbind.fill <- function(...) {
# @keyword manip
compact <- function(l) Filter(Negate(is.null), l)
+# Convert list to data frame
+# Works like cbind, but crams everything into a column
+#
+# @keyword internal
as_df <- function(output) {
if (length(output) == 0) return(data.frame())
# Convert list to data.frame
View
2 R/simplify-array.r
@@ -5,7 +5,7 @@
# @arguments list of input data
# @arguments a data frame of labels, one row for each element of res
# @arguments should extra dimensions be dropped (TRUE) or preserved (FALSE)
-# @keywords internal
+# @keyword internal
list_to_array <- function(res, labels = NULL, .drop = FALSE) {
if (length(res) == 0) return(vector())
n <- length(res)
View
2 R/simplify-data-frame.r
@@ -3,7 +3,7 @@
#
# @arguments list of input data
# @arguments a data frame of labels, one row for each element of res
-# @keywords internal
+# @keyword internal
list_to_dataframe <- function(res, labels = NULL) {
if (length(res) == 0) return(data.frame())
View
2 R/simplify-vector.r
@@ -2,7 +2,7 @@
# Reduce/simplify a list of homogenous objects to a vector
#
# @arguments list of input data
-# @keywords internal
+# @keyword internal
list_to_vector <- function(res) {
if (length(res) == 0) return(vector())
n <- length(res)
View
2 R/split-data-frame.r
@@ -53,7 +53,7 @@ splitter_d <- function(data, .variables = NULL, drop = TRUE) {
#
# @arguments list of variables to split up by
# @argument whether all possible combinations should be considered, or only those present in the data
-# @keywords internal
+# @keyword internal
split_labels <- function(splits, drop) {
factors <- llply(splits, addNA, ifany = TRUE)
splitv <- addNA(interaction(factors, drop = drop, lex.order = TRUE),
View
4 R/split.r
@@ -2,7 +2,7 @@
# Subset splits
# Subset splits, ensuring that labels keep matching
#
-# @keywords internal
+# @keyword internal
"[.split" <- function(x, i, ...) {
structure(
NextMethod(),
@@ -26,7 +26,7 @@ as.list.split <- function(x, ...) {
# Print split
# Don't print labels, so it appears like a regular list
#
-# @keywords internal
+# @keyword internal
print.split <- function(x, ...) {
print(as.list(x))
}
View
2 R/utils.r
@@ -11,7 +11,7 @@ is.discrete <- function(x) is.factor(x) || is.character(x) || is.logical(x)
# Un-rowname
# Strip rownames from an object
#
-# @keywords internal
+# @keyword internal
unrowname <- function(x) {
rownames(x) <- NULL
x
View
11 man/aaply-ym.rd
@@ -27,16 +27,7 @@ always return an array, and when the function returns >1 d data structures,
those dimensions are added on to the highest dimensions, rather than the
lowest dimensions. This makes \code{aaply} idempotent, so that
\code{apply(input, X, identity)} is equivalent to \code{aperm(input, X)}.
-
-
-@keyword manip
-@arguments matrix, array or data frame to be processed
-@arguments 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
-@arguments function to apply to each piece
-@arguments other arguments passed on to \code{.fun}
-@arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
-@arguments should extra dimensions of length 1 be dropped, simplifying the output. Defaults to \code{TRUE}
-@value if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)}
+}
\examples{dim(ozone)
aaply(ozone, 1, mean)
View
3 man/adply-du.rd
@@ -20,8 +20,7 @@ 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 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()}).
-}
+with zero rows and columns (\code{data.frame()}).}
\examples{}
\keyword{manip}
View
10 man/alply-wh.rd
@@ -24,15 +24,7 @@ If there are no results, then this function will return a list of length 0
\code{alply} is somewhat similar to \code{\link{apply}} for cases where the
results are not atomic.
-
-
-@keyword manip
-@arguments matrix, array or data frame to be processed
-@arguments 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
-@arguments function to apply to each piece
-@arguments other arguments passed on to \code{.fun}
-@arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
-@value list of results}
+}
\examples{alply(ozone, 3, quantile)
alply(ozone, 3, function(x) table(round(x)))}
View
17 man/as-df-d2.rd
@@ -0,0 +1,17 @@
+\name{as_df}
+\alias{as_df}
+\title{Convert list to data frame}
+\author{Hadley Wickham <h.wickham@gmail.com>}
+
+\description{
+Works like cbind, but crams everything into a column
+}
+\usage{as_df(output)}
+\arguments{
+\item{output}{}
+}
+
+\details{}
+
+\examples{}
+\keyword{internal}
View
2 man/create-progress-bar-4d.rd
@@ -33,4 +33,4 @@ See the examples.}
l_ply(1:1000, identity, .progress = "tk")
l_ply(1:1000, identity, .progress = "text")
l_ply(1:1000, identity, .progress = progress_text(char = "-"))}
-
+\keyword{utilities}
View
12 man/daply-7r.rd
@@ -23,17 +23,7 @@ by variable and combines the result into an array. If there are no results,
then this function will return a vector of length 0 (\code{vector()}).
\code{daply} with a function that operates column-wise is similar to
-\code{\link{aggregate}}.
-
-
-@keyword manip
-@arguments data frame to be processed
-@arguments variables to split data frame by, as quoted variables, a formula or character vector
-@arguments function to apply to each piece
-@arguments other arguments passed on to \code{.fun}
-@arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
-@arguments should extra dimensions of length 1 be dropped, simplifying the output. Defaults to \code{TRUE}
-@value if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)}
+\code{\link{aggregate}}.}
\examples{daply(baseball, .(year), nrow)
View
3 man/ddply-5k.rd
@@ -30,8 +30,7 @@ length, it will be \code{rbind}ed together and converted to a data frame.
Any other values will result in an error.
}
-\examples{
-ddply(baseball, .(year), "nrow")
+\examples{ddply(baseball, .(year), "nrow")
ddply(baseball, .(lg), c("nrow", "ncol"))
mean_rbi <- function(df) mean(df$rbi, na.rm=TRUE)
View
2 man/failwith-sc.rd
@@ -24,4 +24,4 @@ f(2)
safef <- failwith(NULL, f)
safef(1)
safef(2) }
-
+\keyword{debugging}
View
2 man/get--split-0n.rd
@@ -16,4 +16,4 @@ Subset splits, ensuring that labels keep matching
\details{}
\examples{}
-
+\keyword{internal}
View
2 man/indexed-array-4w.rd
@@ -18,4 +18,4 @@ Create a indexed array, a space efficient way of indexing into a large array
\details{}
\examples{}
-
+\keyword{internal}
View
2 man/indexed-df-uf.rd
@@ -21,4 +21,4 @@ Create a indexed list, a space efficient way of indexing into a large data frame
\details{}
\examples{}
-
+\keyword{internal}
View
10 man/laply-10.rd
@@ -25,15 +25,7 @@ then this function will return a vector of length 0 (\code{vector()}).
it will always return an array, and the output is transposed with respect
\code{sapply} - each element of the list corresponds to a column, not a
row.
-
-
-@keyword manip
-@arguments input list
-@arguments function to apply to each piece
-@arguments other arguments passed on to \code{.fun}
-@arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
-@arguments should extra dimensions of length 1 be dropped, simplifying the output. Defaults to \code{TRUE}
-@value if results are atomic with same type and dimensionality, a vector, matrix or array; otherwise, a list-array (a list with dimensions)}
+}
\examples{laply(baseball, is.factor)
# cf
View
2 man/list-to-array-ki.rd
@@ -16,4 +16,4 @@ Reduce/simplify a list of homogenous objects to an array
\details{}
\examples{}
-
+\keyword{internal}
View
2 man/list-to-dataframe-zb.rd
@@ -15,4 +15,4 @@ Reduce/simplify a list of homogenous objects to a data frame
\details{}
\examples{}
-
+\keyword{internal}
View
17 man/list-to-vector-27.rd
@@ -0,0 +1,17 @@
+\name{list_to_vector}
+\alias{list_to_vector}
+\title{List to vector}
+\author{Hadley Wickham <h.wickham@gmail.com>}
+
+\description{
+Reduce/simplify a list of homogenous objects to a vector
+}
+\usage{list_to_vector(res)}
+\arguments{
+\item{res}{list of input data}
+}
+
+\details{}
+
+\examples{}
+\keyword{internal}
View
12 man/llply-12.rd
@@ -6,12 +6,13 @@
\description{
For each element of a list, apply function then combine results into a list
}
-\usage{llply(.data, .fun = NULL, ..., .progress = "none")}
+\usage{llply(.data, .fun = NULL, ..., .progress = "none", .inform = FALSE)}
\arguments{
\item{.data}{list to be processed}
\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{.inform}{}
}
\value{list of results}
\details{All plyr functions use the same split-apply-combine strategy: they split the
@@ -22,14 +23,7 @@ this function will return a list of length 0 (\code{list()}).
\code{llply} is equivalent to \code{\link{lapply}} except that it will
preserve labels and can display a progress bar.
-
-
-@keyword manip
-@arguments list to be processed
-@arguments function to apply to each piece
-@arguments other arguments passed on to \code{.fun}
-@arguments name of the progress bar to use, see \code{\link{create_progress_bar}}
-@value list of results}
+}
\examples{llply(llply(mtcars, round), table)
llply(baseball, summary)
View
3 man/m-ply-5z.rd
@@ -20,8 +20,7 @@ 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()}).
-}
+then this function will return a list of length 0 (\code{list()}).}
\examples{}
\keyword{manip}
View
2 man/ninteraction-vw.rd
@@ -15,4 +15,4 @@ A purely numerical interaction function that powers \code{aaply}.
\details{}
\examples{}
-
+\keyword{internal}
View
2 man/print-split-fc.rd
@@ -15,4 +15,4 @@ Don't print labels, so it appears like a regular list
\details{}
\examples{}
-
+\keyword{internal}
View
2 man/progress-none-u0.rd
@@ -15,4 +15,4 @@ A progress bar that does nothing
understand - it does nothing!}
\examples{l_ply(1:100, identity, .progress = "none")}
-
+\keyword{internal}
View
8 man/rbind-fill-di.rd
@@ -14,5 +14,11 @@
\details{This is a minor enhancement to \code{\link{rbind}} which adds in columns
that are not present in all inputs.}
-\examples{rbind.fill(mtcars[c("mpg", "wt")], mtcars[c("wt", "cyl")])}
+\examples{rbind.fill(mtcars[c("mpg", "wt")], mtcars[c("wt", "cyl")])
+
+bplayer <- split(baseball, baseball$id)
+system.time(b1 <- do.call("rbind", bplayer))
+rownames(b1) <- NULL
+system.time(b2 <- rbind.fill(bplayer))
+stopifnot(all.equal(b1, b2))}
\keyword{manip}
View
5 man/splat-n6.rd
@@ -12,7 +12,10 @@ Wraps a function in do.call
}
\value{a function}
\details{This is useful when you want to pass a function a row of data frame or
-array, and don't want to manually pull it apart in your function.}
+array, and don't want to manually pull it apart in your function.
+
+@arguments function to splat
+@value a function}
\examples{hp_per_cyl <- function(hp, cyl, ...) hp / cyl
splat(hp_per_cyl)(mtcars[1,])
View
2 man/split-labels-0o.rd
@@ -15,4 +15,4 @@ Create data frame giving labels for split data frame.
\details{}
\examples{}
-
+\keyword{internal}
View
2 man/unrowname-ef.rd
@@ -14,4 +14,4 @@ Strip rownames from an object
\details{}
\examples{}
-
+\keyword{internal}

0 comments on commit b8be46d

Please sign in to comment.