I am interested in generating a list of n random numbers that add up to 1 and are all non-negative, that is, a probability vector. As an example, I have tried the following simple approach:

n=10
v=rbeta(n,shape1=2,shape2=5)
v/sum(v)

However, I don't think this approach is correct, given that the number of degrees of freedom is n-1, instead of n.

Does anyone know how can this be done more correctly?

The first thing that came to my mind was the dirichlet distribution which is a multivariate beta distribution. This package has a function rdirichlet to randomly generate the vectors.

Oh and the dirichlet generation is equivalent to doing what you did - using the beta and dividing by the sum of independent beta draws. It will have n-1 degrees of freedom because of the constraint it sums to 1.

I was surprised to see the beta distribution here. You didn't mention anything about your data to suggest anything about the shape of the distribution.