← Back to R Course | Chapter 1: Getting Started | Lesson 6 of 6

Getting Help

R's help system is like a manual you can open for any tool, by typing a question mark before its name. It tells you what the tool does and how to use it.

In this page:

  1. Getting Help
Syntax
r
?function_name
help(function_name)
example(function_name)

Getting Help

R's built-in help system is accessed with ?function_name or help(function_name), which opens documentation describing a function's arguments and behavior.

example(function_name) runs the documentation's example code directly. Learning to read R's help pages is an essential skill since so much of R's power comes from its huge ecosystem of functions.

Note: ??keyword searches across all installed package documentation, not just an exact function name.

Example: Getting Help

markup
# In an interactive session these open documentation:
# ?mean
# help(mean)

# This prints a short usage description instead, for a non-interactive demo:
cat("Use ?mean or help(mean) in an interactive R session to view docs\n")
cat(args(mean))
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Typing ?mean() with parentheses, which calls the function instead of opening its help; write ?mean.
  2. Searching for a function from a package that is not loaded, when ??topic or help.search() is needed.
  3. Ignoring the Examples section at the bottom of the help page, which shows working code.
Chapter Summary
  • R is a language for working with data, and you can run code in the console or from scripts.
  • Comments document your code, and print() and cat() display results.
  • Getting help lets you look up how functions work.
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.