R programming question

One of the functions we will be using often is sample() . Read the help file for sample() using ?sample . Now take a random sample of size 1 from the numbers 13 to 24 and report back the weight of the mouse represented by that row. Make sure to type set.seed(1) to ensure that everybody gets the same answer.

You need a way to get the numbers from 13 to 24 into the sample function. Here is one way, there are probably others:

set.seed(1)
x <- seq( from = 13, to = 24, by = 1)
sample( x, 1)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.