generate multinomial random varibles with varying sample size in R
问题 I need to genereate multinomial random variables with varying sample size. Let say i already generated my sample sizes as follows, samplesize =c(50,45,40,48) then i need to generate multinomial random variables based on this varying sample size. I tried this using a for loop and using a apply function(sapply). Using For loop , p1=c(0.4,0.3,0.3) for( i in 1:4) { xx1[i]=rmultinom(4, samplesize[i], p1) } If my code is correct then i should get a matrix that have 4 columns and 3 rows. Where