Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Introduction
In this post, 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 that can supplement the built in help system. In the second section, we will look at various ways to access the built in help system of R. Let us get started!
Online Resources
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.
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.
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 Community is similar to Stack Overflow. You can ask questions related to RStudio, Shiny, tidyverse and other RStudio products.
r4ds Community
An online learning community that brings learners and mentors on a single platform. You can learn more about the community here.
RStudio Resources
RStudio has very good resources including cheatsheets, webinars and blogs.
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.
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.
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.
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.
help.start() ## starting httpd help server ... done ## If nothing happens, you should open ## 'http://127.0.0.1:19951/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(plot) ?plot
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
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!
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
Package Documentation
library
Access the documentation of a package using help()
inside library()
. The package need not be installed for accessing the documentation.
library(help = 'ggplot2')
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') ## Warning: vignette 'dplyr' not found
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()
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
Summary
To sum it up, the R community is very beginner friendly and we hope you will find all the above resources, both internal help system and online resources useful.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.