Research and Statistical Support

UIT | ACUS | Help Desk | Training | About Us | Publications | RSS Home

Back to the Do it yourself Introduction to R

(1) What’s in a library? The answer is that many things can be contained in a library. The libraries are bundles of code used to conduct analysis, create graphs, etc. Libraries usually also contain some data which can be loaded and used for a library provided example. At this point, you’re likely thinking, so what; how do I use what’s in a library? Well, the bad news is that you need to know what is in a particular library before you can use it. The good news, of course, is that it’s easy to discover what’s in a particular library. This leads us to one of the many ways we can seek help in R. Working from previous notes, let’s take a look at the base library which comes installed with the base installation of R and loads upon start up of the program R. In the console, type the following and hit the enter key:

help(base)

There are some things to notice in the new help window. First, at the top of the window; you’ll see the topic you asked for help on (typically a function), the package in which this help query topic is found, and R Documentation which is where this help comes from. The key information for this particular library help is what the library does or what can it do; which is displayed in the details section.

This package contains the basic functions which let R function as a language: arithmetic, input/output, basic programming support, etc. 

Also note that this is a rare instance when the package help does not contain a list of the functions available in the package. However, it does tell us what to do to get the complete list of functions:

library(help=”base”)

which does give us a complete list of functions and a brief description of their use. So, what is a function? Well, let’s take a look at:

help(“function”)

This help window is more typical of what you’ll see when using the console help function. There are key elements here which appear in most help documentation; those listed in red (e.g. description, usage, arguments, details, etc.). Especially important is what we find at the bottom of the help window; the examples. Although a bit sophisticated for us right now; what we need to know is that all examples listed in these types of help windows can be copied and pasted into the console and they will work—and importantly can then be modified for our particular use. We will use this approach in later notes to see how to do a particular analysis and apply it to our own data.

(2) Finding the right library. If we are interested in finding a library that will allow us to do some task or analysis; then we have a multitude of choices for tracking down what library we need or want given the likelihood of multiple libraries able to do a given task. If we start by clicking on the ‘Help’ button in the task bar at the top of the console, we find a variety of help options. Two of my most frequently used strategies for finding help are (1) ‘HTML help’ which opens your default browser to the online R help index and (2) ‘Search help…’ which searches help files for whatever topic you enter. First, a note of caution; if you have all the available packages downloaded and installed, the ‘Search help…’ will take a minute or more to collect all the results for just about any topic you search, often resulting in a large list of returns. For this reason, I typically use the HTML help first,

because I can click on the ‘Search Engine & Keywords’ to look for packages, functions, or other forms of information on a particular topic; or I can click on ‘Packages’ to review the packages’ descriptions and then click on and review a particular package’s documentation and related functions. There are other ways of finding help, often more efficient; such as searching Google using “R xxxxxxx” where xxxxxxx is the topic of interest, or using the Rseek search engine. Using Google will inevitably lead you to one of the many very useful blogs created by R users who, not long ago were in the exact same situation you might be…looking for help with some function or library. Also keep in mind there are several R Reference Cards available; I have this one posted on the web page because, I prefer it to others. Of course, there are also the help options in the R console: ‘FAQ on R’, ‘FAQ on R for Windows’, and the help ‘Manuals (in PDF)’ – all of which should be considered recommended reading.

It is often intimidating to see how much help is available and realize finding what you want can become an adventure in and of itself. But, imagine how ridiculous someone might find it if we complained about having too much help available for a software package we were learning. ?.?.?

 

Back to the Do it yourself Introduction to R

UNT home page | Search UNT | UNT news | UNT events

Contact Information

Jon Starkweather, PhD

Jonathan.Starkweather@unt.edu

940-565-4066

Richard Herrington, PhD

Richard.Herrington@unt.edu

940-565-2140

Last updated: 01/21/14 by Jon Starkweather.

UIT | ACUS | Help Desk | Training | About Us | Publications | RSS Home