R/RcppExports.R

Defines functions E_num E_cum E_next

Documented in E_cum E_next E_num

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Get the Eddington number for cycling
#'
#' Gets the \href{https://en.wikipedia.org/wiki/Arthur_Eddington#Eddington_number_for_cycling}{Eddington number for cycling}.
#' The Eddington Number for cycling, \emph{E}, is the
#' maximum number where a cyclist has ridden \emph{E} miles in \emph{E} days.
#'
#' The Eddington Number for cycling is related to computing the rank of an
#' integer partition, which is the same as computing the side length of its
#' \href{https://en.wikipedia.org/wiki/Durfee_square}{Durfee square}. Another
#' relevant application of this metric is computing the
#' \href{https://doi.org/10.1073/pnas.0507655102}{Hirsch index} for
#' publications.
#'
#' This is not to be confused with the
#' \href{https://en.wikipedia.org/wiki/Eddington_number}{Eddington Number in
#' astrophysics}, \eqn{N_{Edd}}, which represents the number of protons in the
#' observable universe.
#'
#' @param rides A vector of mileage, where each element represents a single
#'   day.
#'
#' @return An integer which is the Eddington cycling number for the
#'   data provided.
#'
#' @seealso \code{\link{E_cum}}, \code{\link{E_next}}, \code{\link{E_req}},
#'   \code{\link{E_sat}}
#'
#' @examples
#' # Randomly generate a set of 15 rides
#' rides <- rgamma(15, shape = 2, scale = 10)
#'
#' # View the rides sorted in decreasing order
#' setNames(sort(rides, decreasing = TRUE), seq_along(rides))
#'
#' # Get the Eddington number
#' E_num(rides)
#' @export
E_num <- function(rides) {
    .Call('_eddington_E_num', PACKAGE = 'eddington', rides)
}

#' Calculate the cumulative Eddington number
#'
#' This function is much like \code{\link{E_num}} except it provides
#' a cumulative Eddington number over the vector rather than a single summary
#' number.
#'
#' @inheritParams E_num
#' @seealso \code{\link{E_next}}, \code{\link{E_num}}, \code{\link{E_req}},
#'   \code{\link{E_sat}}
#' @return An integer vector the same length as \code{rides}.
#' @export
E_cum <- function(rides) {
    .Call('_eddington_E_cum', PACKAGE = 'eddington', rides)
}

#' Get the number of rides required to increment to the next Eddington number
#'
#' Get the number of rides required to increment to the next Eddington number.
#'
#' @inheritParams E_num
#' @seealso \code{\link{E_cum}}, \code{\link{E_num}}, \code{\link{E_req}},
#'   \code{\link{E_sat}}
#' @return A named list with the current Eddington number (\code{E}) and the
#'   number of rides required to increment by one (\code{req}).
#' @export
E_next <- function(rides) {
    .Call('_eddington_E_next', PACKAGE = 'eddington', rides)
}

# Register entry points for exported C++ functions
methods::setLoadAction(function(ns) {
    .Call('_eddington_RcppExport_registerCCallable', PACKAGE = 'eddington')
})

Try the eddington package in your browser

Any scripts or data that you put into this service are public.

eddington documentation built on March 24, 2020, 5:08 p.m.