I am having coding the following in R I want to pick 10 random numbers from a standard normal distribution whose sum equals 5. I have the following code so far (below), but this returns "numeric(0)" when the random numbers don't satisfy the condition. What I want is to choose 10 random numbers that do satisfy this condition. Is there a way to re-scale these numbers once they have been picked, or can I somehow insert a condition for this into "rnorm" ? Help very much appreciated!
a <- rnorm(10, 0, 1)
ones <- matrix(1, nrow=10, ncol=1 )
A <- a[t(a) %*% ones == 5]