Sample

Create a vector of integers (x) with the probability of f for each integer.

sample(1:3,50,prob=c(0.5,0.15,0.35),replace=T))