Hi everybody 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 be too hard to write it for myself, but if there's a preexisting one.. I searched the documentation and the help archive, but could not find anything helpful. > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 2.0 year 2005 month 10 day 06 svn rev 35749 language R Thanks a lot. Christian
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}}