Introduction


In this module, 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 online resources and in the second section, we will explore the various ways to access the built in help system of R. Let us get started!

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.

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 the R community by adding your blog to R Bloggers.

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.


RStudio Community


RStudio has very good resources including cheat sheets, webinars and blogs.


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.


r4ds Community


An online learning community that brings learners and mentors on a single platform. You can learn more about the community here.


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.


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.

Internal


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

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

help.start


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

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

help


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

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.

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(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..

example


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

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

library


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

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.

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

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.

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.

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