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:
Syntax
?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
# 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))
Login to try C/C++/Java/PHP code in the editor
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
- Typing
?mean()with parentheses, which calls the function instead of opening its help; write?mean. - Searching for a function from a package that is not loaded, when
??topicorhelp.search()is needed. - 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()andcat()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: