Lesson 2. Get Help with R - Data Science for Scientists 101


Getting help

Learning Objectives

At the end of this activity, you will be able to:

  • List 2 ways that you can get help when you are stuck using R.
  • List several features of R that makes it a versatile tool for scientific programming.

What You Need

A computer with internet access.

Basics of R

R is a versatile, open source programming/scripting language that’s useful both for statistics but also data science. Inspired by the programming language S.

  • Free/Libre/Open Source Software under the GPL version 2.
  • Superior (if not just comparable) to commercial alternatives. R has over 7,000 user contributed packages at this time. It’s widely used both in academia and industry.
  • Available on all platforms.
  • Not just for statistics, but also general purpose programming.
  • For people who have experience in programmming: R is both an object-oriented and a so-called functional language.
  • Large and growing community of peers.

Seeking Help

Below outlines a few ways that you can get help when you are stuck in R.

I know the name of the function I want to use, but I’m not sure how to use it.

If you need help with a specific function, let’s say barplot(), you can type:

?barplot

When you use the ?barplot in the R console, you asking R to look for the documentation for the barplot() function.

If you just need to remind yourself of the names of the arguments that can be used with the function, you can use:

args(lm)

I want to use a function that does X, there must be a function for it but I don’t know which one…

If you are looking for a function to do a particular task, you can use help.search() function, which is called by the double question mark ??. However, this only looks through the installed packages for help pages with a match to your search request

??kruskal

If you can’t find what you are looking for, you can use the rdocumention.org website that searches through the help files across all packages available.

I am stuck…I get an error message that I don’t understand.

Start by googling the error message. However, this doesn’t always work very well because often, package developers rely on the error catching provided by R. You end up with general error messages that might not be very helpful to diagnose a problem (e.g. “subscript out of bounds”). If the message is very generic, you might also include the name of the function or package you’re using in your query.

However, you should check StackOverflow. Search using the [r] tag. Most questions have already been answered, but the challenge is to use the right words in the search to find the answers: http://stackoverflow.com/questions/tagged/r

The Introduction to R can also be dense for people with little programming experience but it is a good place to understand the underpinnings of the R language.

The R FAQ is dense and technical but it is full of useful information.

Where to Get Help

  • Ask your colleagues: if you know someone with more experience than you, they might be able to help you.
  • StackOverflow: if your question hasn’t been answered before and is well crafted, chances are you will get an answer in less than 5 min. Remember to follow their guidelines on how to ask a good question.
  • There are also some topic-specific mailing lists (GIS, phylogenetics, etc…), the complete list is here.

More Resources

Leave a Comment