[R] random generation of a factor
Rau, Roland
Rau at demogr.mpg.de
Mon May 22 12:55:02 CEST 2006
Hi,
>
> Does anybody know a function that generates a factor of
> length N with K
> levels given the proportions c(p1, p2,... ,pk)? It would not
## does this code piece help you?
mydata <- c("yesterday", "today", "tomorrow")
myproportions <- c(0.3, 0.5, 0.2)
n <- 20
sample(x=mydata, size=n, replace=TRUE, prob=myproportions)
cat("Best,\nRoland\n")
----------
This mail has been sent through the MPI for Demographic Rese...{{dropped}}
More information about the R-help
mailing list