Q:

How to generate a specified number of Unique random numbers in R

I am trying to generate 25 random numbers with the range (1:10) by using sample(rep(1:10), 25, replace = TRUE). The problem is out of the 25 generated numbers, sometimes there are only 7 or 8 unique numbers. I want to it have all the 10 numbers in the range 1-10. 
Here is an example depicting the problem where the number 9 is missing: 
> set.seed(7)
> unique(sample(rep(1:10), 25, replace = TRUE))
[1] 10  4  2  1  3  8  5  6  7

A:

How about?
set.seed(7)
x <- c(sample(1:10, 10), sample(1:10, 15, replace = T))
length(unique(x))
x

[1] 10  4  1  8  2  9  6  3  7  5  2  3  8  1  5  1  6  1 10  4  7  3 10 10 10

Based on comments, this is pbb even shorter: sample(c(1:10, sample(1:10, 15, replace = T)), 25)

