Getting help in R

1085

As part of Learn Data analysis using R tutorials. This post explains how to use help in R or how to find help inside R.

There is extensive online help in the R system, the best starting point is to run the function help.start(). This will launch a local page inside your browser with links to the R manuals, R FAQ, a search engine and other links.

Help function

Now let’s see how to get help on a particular function. In the R Console, the function help can be used to see the help file of a specific function.

Example: Getting help for mean function in R

Use the following command to get help on mean function.

help(mean)

You will get the following Output explaining arguments available in function and examples on how to use the function.

Arithmetic Mean

Description:

     Generic function for the (trimmed) arithmetic mean.

Usage:

     mean(x, ...)
     
     ## Default S3 method:
     mean(x, trim = 0, na.rm = FALSE, ...)
     
Arguments:

       x: An R object.  Currently there are methods for numeric/logical
          vectors and date, date-time and time interval objects.
          Complex vectors are allowed for ‘trim = 0’, only.

    trim: the fraction (0 to 0.5) of observations to be trimmed from
          each end of ‘x’ before the mean is computed.  Values of trim
          outside that range are taken as the nearest endpoint.

   na.rm: a logical value indicating whether ‘NA’ values should be
          stripped before the computation proceeds.

     ...: further arguments passed to or from other methods.

Value:

     If ‘trim’ is zero (the default), the arithmetic mean of the values
     in ‘x’ is computed, as a numeric or complex vector of length one.
     If ‘x’ is not logical (coerced to numeric), numeric (including
     integer) or complex, ‘NA_real_’ is returned, with a warning.

If ‘trim’ is non-zero, a symmetrically trimmed mean is computed

with a fraction of ‘trim’ observations deleted from each end
before the mean is computed.

References:

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
Language_. Wadsworth & Brooks/Cole.

See Also:

‘weighted.mean’, ‘mean.POSIXct’, ‘colMeans’ for row and column
means. 
Examples:

x <- c(0:10, 50)
xm <- mean(x)
c(xm, mean(x, trim = 0.10))

help.search Function

Use the function help.search to list help files that contain a certain word. Use the following command to get help on word “linear regression”.

help.search("linear regression")

You will get the following Output

Help files with alias or concept or title matching ‘linear regression’
using fuzzy matching:


datasets::anscombe Anscombe's Quartet of 'Identical' Simple Linear
Regressions
KernSmooth::dpill Select a Bandwidth for Local Linear Regression
MASS::area Adaptive Numerical Integration
Concepts: Non-linear Regression
MASS::rms.curv Relative Curvature Measures for Non-Linear
Regression
Concepts: Non-linear Regression
stats::D Symbolic and Algorithmic Derivatives of Simple
Expressions
Concepts: Non-linear Regression
stats::getInitial Get Initial Parameter Estimates
Concepts: Non-linear Regression
stats::nlm Non-Linear Minimization
Concepts: Non-linear Regression
stats::nls Nonlinear Least Squares
Concepts: Non-linear Regression
stats::nls.control Control the Iterations in nls
Concepts: Non-linear Regression
stats::optim General-purpose Optimization
Concepts: Non-linear Regression
stats::plot.profile.nls
Plot a profile.nls Object
Concepts: Non-linear Regression
stats::predict.nls Predicting from Nonlinear Least Squares Fits
Concepts: Non-linear Regression
stats::profile.nls Method for Profiling nls Objects
Concepts: Non-linear Regression
stats::vcov Calculate Variance-Covariance Matrix for a
Fitted Model Object
Concepts: Non-linear Regression

Type ’help(FOO, package = PKG)’ to inspect entry ’FOO(PKG) TITLE’.

Each package in R comes up with manual which can be accessed from R or can be read from CRAN.

 

Previous articleLearn Data analysis in R
Next articleKeyboard shortcuts to work between Workspaces in Elementary OS
A.Sulthan, Ph.D.,
Author and Assistant Professor in Finance, Ardent fan of Arsenal FC. Always believe "The only good is knowledge and the only evil is ignorance - Socrates"
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments