#' @title Generate Random
#' @description Generate rndom sample, user will need to supply size of sample,
#' distribution name and additional paramenter to run the disribution.
#'
#' The function calls \code{rnorm} for normal samples, \code{rbinom} and \code{rpois} forr poisson samples
#'
#' The function create an R6 object with all the required information.
#'
#' @param n size of sample
#' @param dist distributions that you can choose, Default: c("Normal", "Binomial", "Poisson")
#' @param ... additional paramenter to run disribution
#' @return R6 distribution object
#' @rdname generateRandom
#' @export
generateRandom <- function(n, dist = c("Normal","Binomial", "Poisson"), ...){
dist <- match.arg(dist)
if(dist == "Normal"){
vec <- rnorm(n = n,...)
}else if (dist == "Binomial"){
vec <- rbinom(n = n,...)
} else if( dist == "Poisson"){
vec <- rpois(n=n, ...)
}
out <- distribution$new()
out$sample <- vec
out$dist <- dist
out$params <- c(...)
return(out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.