Skip to content

Commit

Permalink
Prepare for CRAN tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aphalo committed Nov 12, 2023
1 parent 1ee0a50 commit e7bed50
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ggpmisc
Type: Package
Title: Miscellaneous Extensions to 'ggplot2'
Version: 0.5.4-1.9001
Version: 0.5.5
Date: 2023-11-12
Authors@R:
c(
Expand Down
25 changes: 17 additions & 8 deletions R/stat-peaks.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#' This method finds peaks (local maxima) in a vector, using a user selectable
#' span and size threshold relative to the tallest peak (global maximum).
#'
#' @param x numeric vector
#' @param x numeric vector.
#' @param ignore_threshold numeric value between 0.0 and 1.0 indicating the size
#' threshold below which peaks will be ignored.
#' threshold below which peaks will be ignored, or a negative value >= -1,
#' to ignore peaks above a threshold. These values are relative to the range
#' of \code{x}.
#' @param span a peak is defined as an element in a sequence which is greater
#' than all other elements within a window of width span centered at that
#' element. The default value is 3, meaning that a peak is bigger than both of
Expand All @@ -20,12 +22,12 @@
#' peaks in vector \code{x} and can be used to extract the rows corresponding
#' to peaks from a data frame.
#'
#' @details This function is a wrapper built on function
#' @details This function is a wrapper built onto function
#' \code{\link[splus2R]{peaks}} from \pkg{splus2R} and handles non-finite
#' (including NA) values differently than \code{peaks}, instead of giving an
#' error when \code{na.rm = FALSE} they are replaced with the smallest finite
#' value in \code{x}. \code{span = NULL} is treated as a special case and
#' returns \code{max(x)}.
#' error when \code{na.rm = FALSE} and \code{x} contains \code{NA} values,
#' \code{NA} values are replaced with the smallest finite value in \code{x}.
#' \code{span = NULL} is treated as a special case and returns \code{max(x)}.
#'
#' @note The default for parameter \code{strict} is \code{FALSE} in functions
#' \code{peaks()} and \code{find_peaks()}, as in \code{stat_peaks()} and in
Expand All @@ -44,14 +46,21 @@
#' as.numeric = TRUE) # years -> as numeric
#'
#' which(find_peaks(lynx_num.df$lynx, span = 31))
#' lynx_num.df[find_peaks(lynx_num.df$lynx, span = 31), ]
#' lynx_num.df[find_peaks(lynx_num.df$lynx, span = 15), ]
#' lynx_num.df[find_peaks(lynx_num.df$lynx, span = NULL), ]
#' lynx_num.df[find_peaks(lynx_num.df$lynx,
#' span = 31,
#' ignore_threshold = 0.75), ]
#'
#' lynx_datetime.df <-
#' try_tibble(lynx,
#' col.names = c("year", "lynx")) # years -> POSIXct
#'
#' which(find_peaks(lynx_datetime.df$lynx, span = 31))
#' lynx_datetime.df[find_peaks(lynx_num.df$lynx, span = 31), ]
#' lynx_datetime.df[find_peaks(lynx_datetime.df$lynx, span = 31), ]
#' lynx_datetime.df[find_peaks(lynx_datetime.df$lynx,
#' span = 31,
#' ignore_threshold = 0.75), ]
#'
find_peaks <-
function(x,
Expand Down
9 changes: 5 additions & 4 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ reference:
- stat_multcomp
- use_label
- title: Utilities
desc: Low level functions that can be useful to developers of other ggplot2 extensions.
desc: Low level functions used to build some of the functions above, but possibly useful also in other contexts.
contents:
- swap_xy
- keep_tidy
- find_peaks
- coef.lmodel2
- confint.lmodel2
- predict.lmodel2
- keep_tidy
- swap_xy
- title: Changes
desc: Geometries, statistics and functions moved to package 'gginnards'.
desc: List of geometries, statistics and functions moved to package 'gginnards'.
contents:
- Moved

Expand Down
25 changes: 17 additions & 8 deletions man/find_peaks.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e7bed50

Please sign in to comment.