Chapter 5 Getting Help in R

5.1 Introduction

In this chapter, we will learn about the different methods of getting help in R. Often we get stuck while doing some analysis as either we do not know the correct function to use or its syntax. It is important for anyone who is new to R to know the right place to look for help. There are two ways to look for help in R:

  • built in help system
  • online

In the first section, we will look at various ways to access the built in help system of R. In the second section, we will look at various online resources that can supplement the built in help system. Let us get started!

5.2 Online Resources

5.2.1 R Bloggers

R Bloggers aggregates blogs written in english from across the globe. This is the first place you want to visit if you want help with R, data analysis, visualization and machine learning. There are blogs on a wide range of topics and the latest content is delivered to your inbox if you subscribe. If you are a blogger yourself, share it with th R community by adding your blog to R Bloggers.

5.2.2 Stack Overflow

Stack Overflow is a great place to visit if you are having trouble with R code or packages. Chances are high that someone has already encountered the same or similar problem and you can use the answers given by R experts. In case you have encountered a new problem or issue, you can ask for help by providing a reproducible example of your analysis along with the R code. Use the reprex package to create reproducible examples.

5.2.3 Twitter

The R community is very active on Twitter and there are lot of R experts who are willing to help those who are new to R. Use the hashtag #rstats if you are asking for help or guidance on Twitter.

5.2.4 RStudio Community

RStudio Community is similar to Stack Overflow. You can ask questions related to RStudio, Shiny and tidyverse.

5.2.5 RStudio

RStudio has very good resources including cheatsheets, webinars and blogs.

5.2.6 Reddit

Reddit is another place where you can look for help. The discussions are moderated by R experts. There are subreddits for Rstats, Rlanguage, Rstudio and Rshiny.

5.2.7 R Weekly

Visit RWeekly to get regular updates about the R community. You can find information about new packages, blogs, conferences, workshops, tutorials and R jobs.

5.2.8 R User Groups

There are several R User Groups active across the globe. You can find the list here. Join the local user group to meet, discuss and learn from other R enthusiasts and experts.

5.2.9 Data Helpers

Data Helpers is a list of data analysts, scientists and engineers willing to offer guidance put together by Angela Bassa. Visit the website to learn more about how you can approach for help and guidance.

5.3 Internal

In this section, we will look at the following functions:

  • help.start()
  • help()
  • ?
  • ??
  • help.search()
  • demo()
  • example()
  • library()
  • vignette()
  • browseVignettes()

5.3.1 help.start

The help.start() function opens the documetation page in your browser. Here you can find manuals, reference and other materials.

help.start()
## starting httpd help server ... done
## If nothing happens, you should open
## 'http://127.0.0.1:28961/doc/html/index.html' yourself

5.3.2 help

Use help() to access the documentation of functions and data sets. ? is a shortcut for help() and returns the same information.

help(plot)
?plot

5.3.3 help.search

help.search() will search all sources of documentation and return those that match the search string. ?? is a shortcut for help.search() and returns the same information.

help.search('regression')
??regression

5.3.4 demo

demo displays an interactive demonstration of certain topics provided in a R package. Typing demo() in the console will list the demos available in all the R packages installed.

demo()
demo(scoping)
## 
## 
##  demo(scoping)
##  ---- ~~~~~~~
## 
## > ## Here is a little example which shows a fundamental difference between
## > ## R and S.  It is a little example from Abelson and Sussman which models
## > ## the way in which bank accounts work.    It shows how R functions can
## > ## encapsulate state information.
## > ##
## > ## When invoked, "open.account" defines and returns three functions
## > ## in a list.  Because the variable "total" exists in the environment
## > ## where these functions are defined they have access to its value.
## > ## This is even true when "open.account" has returned.  The only way
## > ## to access the value of "total" is through the accessor functions
## > ## withdraw, deposit and balance.  Separate accounts maintain their
## > ## own balances.
## > ##
## > ## This is a very nifty way of creating "closures" and a little thought
## > ## will show you that there are many ways of using this in statistics.
## > 
## > #  Copyright (C) 1997-8 The R Core Team
## > 
## > open.account <- function(total) {
## + 
## +     list(
## +     deposit = function(amount) {
## +         if(amount <= 0)
## +         stop("Deposits must be positive!\n")
## +         total <<- total + amount
## +         cat(amount,"deposited. Your balance is", total, "\n\n")
## +     },
## +     withdraw = function(amount) {
## +         if(amount > total)
## +         stop("You don't have that much money!\n")
## +         total <<- total - amount
## +         cat(amount,"withdrawn.  Your balance is", total, "\n\n")
## +     },
## +     balance = function() {
## +         cat("Your balance is", total, "\n\n")
## +     }
## +     )
## + }
## 
## > ross <- open.account(100)
## 
## > robert <- open.account(200)
## 
## > ross$withdraw(30)
## 30 withdrawn.  Your balance is 70 
## 
## 
## > ross$balance()
## Your balance is 70 
## 
## 
## > robert$balance()
## Your balance is 200 
## 
## 
## > ross$deposit(50)
## 50 deposited. Your balance is 120 
## 
## 
## > ross$balance()
## Your balance is 120 
## 
## 
## > try(ross$withdraw(500)) # no way..
## Error in ross$withdraw(500) : You don't have that much money!

5.3.5 example

example() displays examples of the specified topic if available.

example('mean')
## 
## mean> x <- c(0:10, 50)
## 
## mean> xm <- mean(x)
## 
## mean> c(xm, mean(x, trim = 0.10))
## [1] 8.75 5.50

5.4 Package Documentation

5.4.1 library

Access the documentation of a package using help() inside library(). The package need not be installed for accessing the documentation.

library(help = 'ggplot2')

5.4.2 vignette

A vignette is a long form guide to a R package. You can access the vignettes available using vignette(). It will display alist of vignettes available in installed packages.

vignette()

To access a specific vignette from a package, specify the name of the vignette and the package.

vignette('dplyr', package = 'dplyr')

5.4.3 browseVignettes

browseVignettes() is another way to access the vignettes in installed packages. It will list the vignettes in each package along with links to the web page and R code.

browseVignettes()

5.4.4 RsiteSearch

RsiteSearch() will search for a specified topics in help pages, vignettes and task views using the search engine at this link and return the result in a browser.

RSiteSearch('glm')
## A search query has been submitted to http://search.r-project.org
## The results page should open in your browser shortly