R Program to generate random numbers using sample
Program
x1 <- sample(1:10)
print(x1)
x2 <- sample(1:10, replace = TRUE)
print(x2)
x3 <- sample(1:10, replace = FALSE)
print(x3)
x4 <- sample(1:10, 10, replace = TRUE)
print(x4)
Output
[1] 8 4 10 2 7 9 1 5 3 6
[1] 3 4 1 6 1 3 1 3 5 2
[1] 7 9 1 4 3 2 8 6 5 10
[1] 2 4 2 5 10 1 8 6 5 8