powered by
This function draws a sample from a user-defined frequency distribution for a categorical variable.
random_state(states, probs)
character vector containing state names.
numeric vector containing probabilities for the states. If these do not add up to 1, they are automatically normalized.
one of the states, drawn randomly according to the specified probabilities.
# NOT RUN { random_state(states=c("very low","low","medium","high","very high"), probs=c(1,1,2,1,1)) # }
Run the code above in your browser using DataLab