R has some great help already built in, with the function help(). Functions often have complicated or unintuitive syntax, so it can be useful to see examples of those functions in action. The function example(function_name) will provide an example of that function!

help(sum)
example(sum)
##
## sum> ## Pass a vector to sum, and it will add the elements together.
## sum> sum(1:5)
## [1] 15
##
## sum> ## Pass several numbers to sum, and it also adds the elements.
## sum> sum(1, 2, 3, 4, 5)
## [1] 15
##
## sum> ## In fact, you can pass vectors into several arguments, and everything gets added.
## sum> sum(1:2, 3:5)
## [1] 15
##
## sum> ## If there are missing values, the sum is unknown, i.e., also missing, ....
## sum> sum(1:5, NA)
## [1] NA
##
## sum> ## ... unless  we exclude missing values explicitly:
## sum> sum(1:5, NA, na.rm = TRUE)
## [1] 15

You can also use ?function_name and ??function_name, to pull up the documentation of that function or package in the Help page on the lower right corner.

As mentioned in the Mini Course home page, Stack Overflow has excellent support. Questions and answers both provide code, so it’s really user-friendly.

I usually google any questions I have, which typically brings me to a Stack Overflow page. Also, if I get error messages that I don’t understand, I copy and paste the whole error message into Google - this gernerally brings me to Stack Overflow, where someone else has already had and answered the problem.

Method Does
help(function_name) brings up documentation in R’s help window
example(function_name) shows and example of the function
?(function_name) same as help
??(function_name) sometimes needed if the function isn’t part of base R
Stack Overflow community of R users