Skip to content

Commit

Permalink
Documentation tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Mar 2, 2011
1 parent dca8b18 commit f67b0f7
Show file tree
Hide file tree
Showing 30 changed files with 72 additions and 117 deletions.
5 changes: 5 additions & 0 deletions NAMESPACE
Expand Up @@ -18,6 +18,11 @@ export(try_default)
export(tryapply)
export(vaggregate)
export(id)
S3method("[", idf)
S3method(names, idf)
S3method(dim, idf)
S3method(as.data.frame, idf)
S3method("[[", idf)
export(idata.frame)
export(join)
export(join.keys)
Expand Down
1 change: 1 addition & 0 deletions R/helper-count.r
@@ -1,4 +1,5 @@
#' Count the number of occurences.
#'
#' Equivalent to \code{as.data.frame(table(x))}, but does not include
#' combinations with zero counts.
#'
Expand Down
4 changes: 3 additions & 1 deletion R/helper-data-frame.r
@@ -1,5 +1,7 @@
#' Make a function return a data frame.
#' Create a new function that returns the existing function wrapped in a data.frame
#'
#' Create a new function that returns the existing function wrapped in a
#' data.frame
#'
#' This is useful when calling \code{*dply} functions with a function that
#' returns a vector, and you want the output in rows, rather than columns
Expand Down
4 changes: 3 additions & 1 deletion R/helper-each.r
@@ -1,5 +1,7 @@
#' Aggregate multiple functions into a single function.
#' Combine multiple functions to a single function returning a named vector of outputs
#'
#' Combine multiple functions to a single function returning a named vector of
#' outputs
#'
#' Each function should produce a single number as output
#'
Expand Down
2 changes: 1 addition & 1 deletion R/helper-mutate.r
@@ -1,4 +1,4 @@
#' Mutate a data frame by adding new columns or replacing existing.
#' Mutate a data frame by adding new or replacing existing columns.
#'
#' This function is very similar to \code{\link{transform}} but it executes
#' the transformations iteratively so that later transformations can use the
Expand Down
1 change: 1 addition & 0 deletions R/helper-quick-df.r
@@ -1,4 +1,5 @@
#' Quick data frame.
#'
#' Experimental version of \code{\link{as.data.frame}} that converts a
#' list to a data frame, but doesn't do any checks to make sure it's a
#' valid format. Much faster.
Expand Down
4 changes: 2 additions & 2 deletions R/helper-round-any.r
@@ -1,4 +1,4 @@
#' Round to multiple of any number
#' Round to multiple of any number.
#'
#' @param x numeric vector to round
#' @param accuracy number to round to
Expand All @@ -16,6 +16,6 @@
#' round_any(135, 10, ceiling)
#' round_any(135, 100, ceiling)
#' round_any(135, 25, ceiling)
round_any <- function(x, accuracy, f=round) {
round_any <- function(x, accuracy, f = round) {
f(x / accuracy) * accuracy
}
4 changes: 3 additions & 1 deletion R/helper-splat.r
@@ -1,5 +1,7 @@
#' `Splat' arguments to a function.
#' Wraps a function in do.call
#'
#' Wraps a function in do.call, so instead of taking multiple arguments, it
#' takes a single named list which will be interpreted as its arguments.
#'
#' 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.
Expand Down
3 changes: 1 addition & 2 deletions R/helper-summarise.r
@@ -1,6 +1,5 @@
#' Summarise a data frame.
#' Create a new data frame that summarises an existing data frame.
#'
#'
#' Summarise works in an analagous way to transform, except instead of adding
#' columns to an existing data frame, it creates a new one. This is
#' particularly useful in conjunction with \code{\link{ddply}} as it makes it
Expand Down
4 changes: 3 additions & 1 deletion R/helper-try.r
@@ -1,5 +1,7 @@
#' Fail with specified value.
#' Modify a function so that it returns a default value when there is an error.
#'
#' Modify a function so that it returns a default value when there is an
#' error.
#'
#' @param default default value
#' @param f function
Expand Down
2 changes: 1 addition & 1 deletion R/id.r
@@ -1,4 +1,4 @@
#' A unique numeric id for each unique row in a data frame.
#' Compute a unique numeric id for each unique row in a data frame.
#'
#' Properties:
#' \itemize{
Expand Down
23 changes: 5 additions & 18 deletions R/immutable.r
Expand Up @@ -10,6 +10,11 @@
#'
#' @param df a data frame
#' @return an immutable data frame
#' @S3method "[" idf
#' @S3method names idf
#' @S3method dim idf
#' @S3method as.data.frame idf
#' @S3method "[[" idf
#' @keywords manip
#' @export
#' @examples
Expand Down Expand Up @@ -37,10 +42,6 @@ idata.frame <- function(df) {
class = c("idf", "environment"))
}

#' Immutable df subsetting
#' @method [ idf
#' @name get1-idf
#' @keywords internal
"[.idf" <- function(x, i, j, drop = TRUE) {
# Single column special cases
if (nargs() == 2) {
Expand Down Expand Up @@ -93,28 +94,14 @@ idata.frame <- function(df) {
class = c("idf", "environment"))
}

#' Immutable df names.
#' @method names idf
#' @keywords internal
names.idf <- function(x) x$`_cols`

#' Immutable df dimensions.
#' @method dim idf
#' @keywords internal
dim.idf <- function(x) c(length(x$`_rows`), length(x$`_cols`))


#' Convert immutable df to regular data frame.
#' @method as.data.frame idf
#' @keywords internal
as.data.frame.idf <- function(x, ...) {
x$`_data`[x$`_rows`, x$`_cols`]
}

#' Extract single column from immutable data frame.
#' @method [[ idf
#' @keywords internal
#' @name get2-idf
"[[.idf" <- function(x, i) {
if (is.numeric(i)) {
i <- names(x)[i]
Expand Down
4 changes: 2 additions & 2 deletions R/quote.r
@@ -1,5 +1,5 @@
#' Quote variables.
#' Create a list of unevaluated expressions for later evaluation
#' Quote variables to create a list of unevaluated expressions for later
#' evaluation.
#'
#' This function is similar to \code{\link{~}} in that it is used to
#' capture the name of variables, not their current value. This is used
Expand Down
7 changes: 4 additions & 3 deletions man/as.data.frame.function.Rd
Expand Up @@ -5,12 +5,13 @@
...)}

\description{
Make a function return a data frame. Create a new
function that returns the existing function wrapped in a
data.frame
Make a function return a data frame.
}

\details{
Create a new function that returns the existing function
wrapped in a data.frame

This is useful when calling \code{*dply} functions with a
function that returns a vector, and you want the output
in rows, rather than columns
Expand Down
9 changes: 0 additions & 9 deletions man/as.data.frame.idf.Rd

This file was deleted.

7 changes: 4 additions & 3 deletions man/count.Rd
Expand Up @@ -4,12 +4,13 @@
\usage{count(df, vars, wt_var)}

\description{
Count the number of occurences. Equivalent to
\code{as.data.frame(table(x))}, but does not include
combinations with zero counts.
Count the number of occurences.
}

\details{
Equivalent to \code{as.data.frame(table(x))}, but does
not include combinations with zero counts.

Speed-wise count is competitive with \code{\link{table}}
for single variables, but it really comes into its own
when summarising multiple dimensions because it only
Expand Down
14 changes: 0 additions & 14 deletions man/defaults.Rd

This file was deleted.

9 changes: 0 additions & 9 deletions man/dim.idf.Rd

This file was deleted.

5 changes: 3 additions & 2 deletions man/each.Rd
Expand Up @@ -5,11 +5,12 @@

\description{
Aggregate multiple functions into a single function.
Combine multiple functions to a single function returning
a named vector of outputs
}

\details{
Combine multiple functions to a single function returning
a named vector of outputs

Each function should produce a single number as output
}
\keyword{manip}
Expand Down
8 changes: 6 additions & 2 deletions man/failwith.Rd
Expand Up @@ -4,8 +4,12 @@
\usage{failwith(default, f, quiet=FALSE)}

\description{
Fail with specified value. Modify a function so that it
returns a default value when there is an error.
Fail with specified value.
}

\details{
Modify a function so that it returns a default value when
there is an error.
}
\value{a function}
\seealso{\code{\link{try_default}}}
Expand Down
9 changes: 0 additions & 9 deletions man/get1-idf.Rd

This file was deleted.

9 changes: 0 additions & 9 deletions man/get2-idf.Rd

This file was deleted.

5 changes: 3 additions & 2 deletions man/id.Rd
@@ -1,9 +1,10 @@
\name{id}
\title{A unique numeric id for each unique row in a data frame.}
\title{Compute a unique numeric id for each unique row in a data frame.}
\usage{id(.variables, drop=FALSE)}

\description{
A unique numeric id for each unique row in a data frame.
Compute a unique numeric id for each unique row in a data
frame.
}

\details{
Expand Down
6 changes: 3 additions & 3 deletions man/mutate.Rd
@@ -1,11 +1,11 @@
\name{mutate}
\alias{mutate}
\title{Mutate a data frame by adding new columns or replacing existing.}
\title{Mutate a data frame by adding new or replacing existing columns.}
\usage{mutate(.data, ...)}

\description{
Mutate a data frame by adding new columns or replacing
existing.
Mutate a data frame by adding new or replacing existing
columns.
}

\details{
Expand Down
9 changes: 0 additions & 9 deletions man/names.idf.Rd

This file was deleted.

11 changes: 7 additions & 4 deletions man/quickdf.Rd
Expand Up @@ -4,10 +4,13 @@
\usage{quickdf(list)}

\description{
Quick data frame. Experimental version of
\code{\link{as.data.frame}} that converts a list to a
data frame, but doesn't do any checks to make sure it's a
valid format. Much faster.
Quick data frame.
}

\details{
Experimental version of \code{\link{as.data.frame}} that
converts a list to a data frame, but doesn't do any
checks to make sure it's a valid format. Much faster.
}
\keyword{internal}
\arguments{
Expand Down
6 changes: 3 additions & 3 deletions man/quoted.Rd
@@ -1,10 +1,10 @@
\name{quoted}
\title{Quote variables.}
\title{Quote variables to create a list of unevaluated expressions for later...}
\usage{.(..., .env=parent.frame())}

\description{
Quote variables. Create a list of unevaluated expressions
for later evaluation
Quote variables to create a list of unevaluated
expressions for later evaluation.
}

\details{
Expand Down
4 changes: 2 additions & 2 deletions man/round_any.Rd
@@ -1,10 +1,10 @@
\name{round_any}
\alias{round_any}
\title{Round to multiple of any number...}
\title{Round to multiple of any number.}
\usage{round_any(x, accuracy, f=round)}

\description{
Round to multiple of any number
Round to multiple of any number.
}
\keyword{manip}
\arguments{
Expand Down
7 changes: 5 additions & 2 deletions man/splat.Rd
Expand Up @@ -4,11 +4,14 @@
\usage{splat(flat)}
\description{
`Splat' arguments to a function. Wraps a function in
do.call
`Splat' arguments to a function.
}

\details{
Wraps a function in do.call, so instead of taking
multiple arguments, it takes a single named list which
will be interpreted as its arguments.

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.
Expand Down
3 changes: 1 addition & 2 deletions man/summarise.Rd
Expand Up @@ -3,8 +3,7 @@
\usage{summarise(.data, ...)}

\description{
Summarise a data frame. Create a new data frame that
summarises an existing data frame.
Summarise a data frame.
}

\details{
Expand Down

0 comments on commit f67b0f7

Please sign in to comment.