Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (5.3k 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
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

Browse Categories

...