# Statistical Analysis: an Introduction using R/R/Help on a function

#### Help on a function[edit]

A common problem in R is knowing which function to use. For instance, we want a function that will produce randomly sampled numbers from 1 to 6. Here's one way of finding out

help.search("random") #list the R functions to do with the word "random"

#The "sample" function is described as “Random Samples and Permutations”: just the thing

help("sample") #get detailed information on the "sample" function

?sample #this is a quicker way of doing the same thing

From the help page, you will see that "sample" picks items at random from a list, the "Usage" section shows that the "sample" function takes up to 4 comma-separated arguments. The "Arguments" section describes what they are:

*x*(a vector specifying the list of items from which to choose)*size*(the number of times to pick an item)*replace*(a TRUE or FALSE value to indicate whether items should be put back into the list after each pick)*prob*(a vector of probabilities, used if we are not equally likely to pick each item)