R/simulate.R

Defines functions simPats

Documented in simPats

##factList is a list each component describes a factor
##  the name is the name of the factor, and value is either
## the proportions of the levels (named); or a function to simulate

 simPats <- function(npat, factList) {
      funs = sapply(factList, is.function)
      ans = lapply(factList, function(x) {
           if( is.function(x) ) x(npat) else
           sample(names(x), npat, replace=TRUE, prob=x)
      })
      as.data.frame(ans)
 }

Try the randPack package in your browser

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

randPack documentation built on Nov. 8, 2020, 5:32 p.m.