0 votes
1 view
in R Programming by (5k points)

a<-c(1,2,0,7,5)

Some languages have a picker -function -- choose one random number from a -- how in R?

1 Answer

0 votes
by (24.7k points)
edited by

To select a random element from a number of elements, you can use the sample() function as follows:

a<-c(1,2,0,7,5)

> sample(a, 1)

[1] 5

If you want to explore more in R programming then watch this R programming tutorial for beginner:

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...