Skip to content

Commit

Permalink
Documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Apr 12, 2009
1 parent be273b8 commit b8be46d
Show file tree
Hide file tree
Showing 41 changed files with 86 additions and 91 deletions.
1 change: 1 addition & 0 deletions R/helper-splat.r
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions R/helper-try.r
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/indexed-array.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/indexed-data-frame.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/ninteraction.r
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 1 addition & 5 deletions R/ply-array.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions R/ply-data-frame.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions R/ply-list.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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") {
Expand Down
1 change: 0 additions & 1 deletion R/ply-mapply.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions R/progress.r
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions R/rbind.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/simplify-array.r
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/simplify-data-frame.r
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
2 changes: 1 addition & 1 deletion R/simplify-vector.r
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/split-data-frame.r
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions R/split.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Subset splits
# Subset splits, ensuring that labels keep matching
#
# @keywords internal
# @keyword internal
"[.split" <- function(x, i, ...) {
structure(
NextMethod(),
Expand All @@ -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))
}
2 changes: 1 addition & 1 deletion R/utils.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions man/aaply-ym.rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions man/adply-du.rd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
10 changes: 1 addition & 9 deletions man/alply-wh.rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)))}
Expand Down
17 changes: 17 additions & 0 deletions man/as-df-d2.rd
Original file line number Diff line number Diff line change
@@ -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}
2 changes: 1 addition & 1 deletion man/create-progress-bar-4d.rd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
12 changes: 1 addition & 11 deletions man/daply-7r.rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions man/ddply-5k.rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion man/failwith-sc.rd
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ f(2)
safef <- failwith(NULL, f)
safef(1)
safef(2) }

\keyword{debugging}
2 changes: 1 addition & 1 deletion man/get--split-0n.rd
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Subset splits, ensuring that labels keep matching
\details{}

\examples{}

\keyword{internal}
2 changes: 1 addition & 1 deletion man/indexed-array-4w.rd
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Create a indexed array, a space efficient way of indexing into a large array
\details{}

\examples{}

\keyword{internal}
2 changes: 1 addition & 1 deletion man/indexed-df-uf.rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Create a indexed list, a space efficient way of indexing into a large data frame
\details{}

\examples{}

\keyword{internal}
10 changes: 1 addition & 9 deletions man/laply-10.rd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion man/list-to-array-ki.rd
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Reduce/simplify a list of homogenous objects to an array
\details{}

\examples{}

\keyword{internal}
2 changes: 1 addition & 1 deletion man/list-to-dataframe-zb.rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Reduce/simplify a list of homogenous objects to a data frame
\details{}

\examples{}

\keyword{internal}
17 changes: 17 additions & 0 deletions man/list-to-vector-27.rd
Original file line number Diff line number Diff line change
@@ -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}
Loading

0 comments on commit b8be46d

Please sign in to comment.