Getting Help


Before we get deeper into the use of R, it is good to know how to seek help when we get stuck. Two functions are illustrated here. If you know the name of a function or the topic, you may use the function help(…) with your function name or topic inside the parenthesis. For example, if you are interested in the function plot(), you can type

> help(plot)

 

and it will pop-up a help manual for plot function. This can be done more quickly by typing a question mark in front of the function in question.

> ?plot

 

Sometimes, you may want to find something related to a certain keyword. Then you may find help.search() useful. Function help.search() will search for all the functions that have the word you specified in their help document such as name, title, concept, keyword. For example,

> help.search("sort")

will list all functions that have the word 'sort' as an alias or in their title. The dunction help.search() also has a shortcut consisting of two question marks preceding the keyword (e.g., ??sort). If you want to learn more about the help function, you may type help(help). Besides the official help pages, you can also explore the Internet, which has many resources.

 

Loading Packages


R is open source software, so many packages are freely available. However, not every package is installed or loaded when you open R.

Watch the following video.

Installing Packages in R (R Tutorial 1.10) MarinStatsLectures [Contents]

alternative accessible content

If you want to use a package that is not yet installed, you need to install it and then load it into R. For example, you may want to use package ISwR, which is a package used in the textbook, to help you while reading along with the textbook. Here is the procedure:

  1. Install package ISwR:

                  Click Set CRAN Mirror… in the Packages options

                  -> Pick the closest server site, eg USA (MA), and click OK

                  -> Click Install Package(s)… in the Packages options

                  -> Pick ISwR

Once it is downloaded you will see something like the following statement. Note that I have deleted some output to save space.  Don't panic if you see a warning here; you may ignore this for the time being.

….

package 'ISwR' successfully unpacked and MD5 sums checked

The downloaded packages are in

C:\Users\ctliu\AppData\Local\Temp\RtmpjNPIgz\downloaded_packages

  1. Load the package ISwR

Once you install the package, you still need to load it into R before use. To load the package, type

> library(ISwR)

Now package ISwR is ready for you to use.

 

You can also install directly from your command line by typing in

> install.packages("packagename")

 

Summary:

Reading: 

 

Assignment: