Skip to content

Commit d012843

Browse files
committed
Doc tweaks for vector functions
1 parent 576973b commit d012843

File tree

8 files changed

+74
-38
lines changed

8 files changed

+74
-38
lines changed

R/stat-summary.r

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,29 @@ summarise_by_x <- function(data, summary, ...) {
170170
merge(summary, unique, by = c("x", "group"), sort = FALSE)
171171
}
172172

173-
#' Wrap up a selection of summary functions from Hmisc to make it easy to use
174-
#' with \code{\link{stat_summary}}.
175-
#'
176-
#' See the Hmisc documentation for details of their options.
177-
#'
173+
#' A selection of summary functions from Hmisc
174+
#'
175+
#' @description
176+
#' These are wrappers around functions from \pkg{Hmsic} designed to make them
177+
#' easier to use with \code{\link{stat_summary}}. See the Hmisc documentation
178+
#' for more details:
179+
#'
180+
#' \itemize{
181+
#' \item \code{\link[Hmisc]{smean.cl.boot}}
182+
#' \item \code{\link[Hmisc]{smean.cl.normal}}
183+
#' \item \code{\link[Hmisc]{smean.sdl}}
184+
#' \item \code{\link[Hmisc]{smedian.hilow}}
185+
#' }
178186
#' @param x a numeric vector
179187
#' @param ... other arguments passed on to the respective Hmisc function.
180-
#' @seealso \code{\link[Hmisc]{smean.cl.boot}},
181-
#' \code{\link[Hmisc]{smean.cl.normal}}, \code{\link[Hmisc]{smean.sdl}},
182-
#' \code{\link[Hmisc]{smedian.hilow}}
188+
#' @return A data frame with columns \code{y}, \code{ymin}, and \code{ymax}.
183189
#' @name hmisc
190+
#' @examples
191+
#' x <- rnorm(100)
192+
#' mean_cl_boot(x)
193+
#' mean_cl_normal(x)
194+
#' mean_sdl(x)
195+
#' median_hilow(x)
184196
NULL
185197

186198
wrap_hmisc <- function(fun) {
@@ -212,12 +224,17 @@ mean_sdl <- wrap_hmisc("smean.sdl")
212224
#' @rdname hmisc
213225
median_hilow <- wrap_hmisc("smedian.hilow")
214226

215-
#' Calculate mean and standard errors on either side.
227+
#' Calculate mean and standard error
228+
#'
229+
#' For use with \code{\link{stat_summary}}
216230
#'
217231
#' @param x numeric vector
218232
#' @param mult number of multiples of standard error
219-
#' @seealso for use with \code{\link{stat_summary}}
233+
#' @return A data frame with columns \code{y}, \code{ymin}, and \code{ymax}.
220234
#' @export
235+
#' @examples
236+
#' x <- rnorm(100)
237+
#' mean_se(x)
221238
mean_se <- function(x, mult = 1) {
222239
x <- stats::na.omit(x)
223240
se <- mult * sqrt(stats::var(x) / length(x))

R/utilities-break.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Cut up numeric vector into useful groups.
1+
#' Discretise numeric data into categorical
22
#'
33
#' \code{cut_interval} makes \code{n} groups with equal range, \code{cut_number}
44
#' makes \code{n} groups with (approximately) equal numbers of observations;

R/utilities-resolution.r

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
#' Compute the "resolution" of a data vector.
1+
#' Compute the "resolution" of a numeric vector
22
#'
33
#' The resolution is the smallest non-zero distance between adjacent
44
#' values. If there is only one unique value, then the resolution is defined
5-
#' to be one.
6-
#'
7-
#' If x is an integer vector, then it is assumed to represent a discrete
8-
#' variable, and the resolution is 1.
5+
#' to be one. If x is an integer vector, then it is assumed to represent a
6+
#' discrete variable, and the resolution is 1.
97
#'
108
#' @param x numeric vector
119
#' @param zero should a zero value be automatically included in the
@@ -15,8 +13,10 @@
1513
#' resolution(1:10)
1614
#' resolution((1:10) - 0.5)
1715
#' resolution((1:10) - 0.5, FALSE)
18-
#' resolution(c(1,2, 10, 20, 50))
19-
#' resolution(as.integer(c(1, 10, 20, 50))) # Returns 1
16+
#'
17+
#' # Note the difference between numeric and integer vectors
18+
#' resolution(c(2, 10, 20, 50))
19+
#' resolution(c(2L, 10L, 20L, 50L))
2020
resolution <- function(x, zero = TRUE) {
2121
if (is.integer(x) || zero_range(range(x, na.rm = TRUE)))
2222
return(1)

_pkgdown.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ reference:
157157
- print.ggproto
158158

159159
- title: Vector helpers
160+
desc: >
161+
ggplot2 also provides a handful of helpers that are useful for creating
162+
visualisations.
160163
contents:
161164
- cut_interval
162165
- hmisc

man/cut_interval.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/hmisc.Rd

Lines changed: 20 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/mean_se.Rd

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/resolution.Rd

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)