If you need help with a specific function, let’s say
barplot(), you can type:
If you just need to remind yourself of the names of the arguments, you can use:
If the function is part of a package that is installed on your computer but don’t remember which one, you can type
If you are looking for a function to do a particular task, you can use
help.search() (but only looks through the installed packages):
If you can’t find what you are looking for, you can use the rdocumention.org website that search through the help files across all packages available.
Start by googling the error message. However, this doesn’t always work very well because often, package developers rely too much 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”).
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:
The Introduction to R can also be dense for people with little programming experience but it is a good place to understand
The R FAQ is dense and technical but it is full of useful information.
The key to get help from someone is for them to grasp your problem rapidly. You should make it as easy as possible for them to pinpoint where the issue might be.
Try to use the correct words to describe your problem. For instance, a package is not the same thing as a library. Most people will understand what you meant, but others have really strong feelings about the difference in meaning. The key point is that it can make things confusing for people trying to help you. Be be as precise as possible when describing your problem
If possible, try to reduce what doesn’t work to a simple reproducible
example. If you can reproduce the problem using a very small
instead of your 50,000 rows and 10,000 columns one, provide the small one with
the description of your problem. When appropriate, try to generalize what you
are doing so even people who are not in your field can understand the question.
To share an object with someone else, if it’s relatively small, you can use the
dput(), it will output R code that can be used to recreate the exact same
object as the one in memory:
dput(head(iris)) # iris is an example data.frame that comes with R
## structure(list(Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, 5.4), ## Sepal.Width = c(3.5, 3, 3.2, 3.1, 3.6, 3.9), Petal.Length = c(1.4, ## 1.4, 1.3, 1.5, 1.4, 1.7), Petal.Width = c(0.2, 0.2, 0.2, ## 0.2, 0.2, 0.4), Species = structure(c(1L, 1L, 1L, 1L, 1L, ## 1L), .Label = c("setosa", "versicolor", "virginica"), class = "factor")), .Names = c("Sepal.Length", ## "Sepal.Width", "Petal.Length", "Petal.Width", "Species"), row.names = c(NA, ## 6L), class = "data.frame")
If the object is larger, provide either the raw file (i.e., your CSV file) with
your script up to the point of the error (and after removing everything that is
not relevant to your issue). Alternatively, in particular if your questions is
not related to a
data.frame, you can save any R object to a file:
The content of this file is however not human readable and cannot be posted directly on stackoverflow. It can how be sent to someone by email who can read it with this command:
some_data <- readRDS(file="~/Downloads/iris.rds")
Last, but certainly not least, always include the output of
as it provides critical information about your platform, the versions of R and
the packages that you are using, and other information that can be very helpful
to understand your problem.
## R version 3.1.2 (2014-10-31) ## Platform: x86_64-pc-linux-gnu (64-bit) ## ## locale: ##  LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C ##  LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 ##  LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 ##  LC_PAPER=en_US.UTF-8 LC_NAME=C ##  LC_ADDRESS=C LC_TELEPHONE=C ##  LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C ## ## attached base packages: ##  stats graphics grDevices utils datasets base ## ## loaded via a namespace (and not attached): ##  evaluate_0.5.5 formatR_1.0 knitr_1.8 stringr_0.6.2 ##  tools_3.1.2
packageDescription("name-of-package"). You may also want to try to email the author of the package directly.