R/fonctions.R

Defines functions fuzzydouble double

Documented in double fuzzydouble

#' double
#'
#' Double value of numbers.
#' @param number a numeric vector.
#'
#' @return A vector of the same length as `number` containing the
#'   transformed values.
#' @export
#'
#' @examples
#' double(2)
#' double(1:4)
double <- function(number) {
  return(2 * number)
}

#' fuzzydouble
#'
#' Double value of numbers with an error
#'
#' Calculate the double values of numbers
#' and add a random error to the result.
#'
#' @param number a numeric vector.
#' @param sd the standard deviation of the Gaussian error added.
#'
#' @return A vector of the same length as `number`
#'  containing the transformed values.
#' @export
#'
#' @examples
#' fuzzydouble(2)
#' fuzzydouble(1:4)
fuzzydouble <- function(number, sd = 1) {
  return(2 * number + stats::rnorm(length(number), 0,
                                   sd))
}
LafontRapnouilTristan/multiple documentation built on Dec. 31, 2020, 2:15 p.m.