Getting Help in R

The simplest way to get help in R is to click on the Help button on the toolbar of the RGui window. Alternatively, if you are connected to the internet, you can type CRAN in Google and search for the help you need at CRAN. However, if you know the name of the function you want help with, you just type a question mark ? at the command line prompt followed by the name of the function. So to get help on read.table, just type

?read.table

Sometimes you cannot remember the precise name of the function, but you know the subject on which you want help (e.g. data input in this case). Use the help.search function (without a question mark) with your query in double quotes like this:

help.search("data input")

and (with any luck) you will see the names of the R functions associated with this query. Then you can use ?read.table to get detailed help.

Other useful functions are find and apropos. The find function tells you what package something is in:

find(lowess)

[1] "package:stats"

while apropos returns a character vector giving the names of all objects in the search list that match your (potentially partial) enquiry:

apropos(lm) [1] ". __C__anova.glm" ". __C__anova.glm.null" ". __C__glm" [4] ". __C__glm.null" ". __C__lm" ". __C__mlm" [7] "anova.glm" "anova.glmlist" "anova.lm" [10] "anova.lmlist" "anova.mlm" "anovalist.lm" [13] "contr.helmert" "glm" "glm.control" [16] "glm.fit" "glm.fit.null" "hatvalues.lm" [19] "KalmanForecast" "KalmanLike" "KalmanRun" [22] "KalmanSmooth" ...

Get The R Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.