R Programming is used in a variety of aspects. Studying Machine Learning Course and making it easy is one of its prime benefits. R Programming is somewhat related to Machine Learning Tutorial as well. If we are having a list suppose a<- c(2,3,8,9,5) and if we want to select a random element from this list, then we will use sample ( a,1). This will give us a random element from the list a.
If your vector length is 1, then use the below line of code, otherwise, it will show unusual behavior :
a[sample(1:length(a),1)]
Now, if you want to get more programming experience in R then you must watch this video tutorial: