I'm trying to generate frequencies randomly to understand gene frequencies in a population using R. I tried this:
freq<- function(x,y) #random frequency generator
{rn<-sample(1:y,x)
sum <- sum(rn)
for(i in 1:x){
RG[i]=rn[i]/sum}
return(RG)
}
Does anyone know how to constrain the sum to a particular value (say, 100) before division?