R/mysample.R

Defines functions mysample

Documented in mysample

#' my sample
#'
#' @param n variable indicating sample size
#' @param iter variable containing iteration times
#' @param time run in the background
#'
#' @return plot
#' @export
#'
#' @examples
#' \dontrun{mysample(n=1000,iter=30,time=1)}
#'
mysample=function(n, iter,time){
  for( i in 1:iter){
    #make a sample
    s=sample(1:10,n,replace=TRUE)
    # turn the sample into a factor
    sf=factor(s,levels=1:10)
    #make a barplot
    barplot(table(sf)/n,beside=TRUE,col=rainbow(10),
            main=paste("Example sample()", " iteration ", i, " n= ", n,sep="") ,
            ylim=c(0,0.2))

    #release the table
    Sys.sleep(time)
}
}
menyangdavila/MATH4753davi0682 documentation built on May 3, 2022, 12:09 a.m.