?function_name
help(function_name)Seeking Help
Adapted from Software Carpentry
Overview
Questions:
- How can I get help in R?
Objectives:
- Use R help files and resources
- Find packages for specific tasks
- Seek help from peers
- Use generative AI responsibly
Reading Help Files
Access help for any function:
Help pages include: Description, Usage, Arguments, Details, Value, See Also, and Examples.
For special operators, use quotes or backticks:
?"<-"
?`<-`
TipRunning Examples
Highlight code examples in help pages and hit Ctrl+Return to run them in RStudio.
Getting Help
Package Vignettes
Packages often include tutorials and extended examples:
vignette() # list all vignettes
vignette(package="dplyr") # list dplyr vignettes
vignette("dplyr") # open specific vignetteSee RStudio cheatsheets for common packages.
Fuzzy Search
Search for functions when you don’t know the exact name:
??function_nameFinding Packages
CRAN Task Views organizes packages by topic.
Getting Help from Others
Online Resources
- Search the internet: Paste your error message and “R” into a search engine
- StackOverflow is particularly helpful; use the
[r]tag - Note: Understand code before copying it
- StackOverflow is particularly helpful; use the
- Ask colleagues: Share your problem with someone more experienced
- Rubber duck debugging: Explaining your problem out loud often reveals the solution
Formulating Good Questions
When asking for help, provide:
dput(your_data) # share your data reproducibly
sessionInfo() # share your R environmentGenerative AI Tools
Tools like ChatGPT can provide helpful suggestions. However:
- Responses are not always reliable - verify accuracy
- They may generate plausible-sounding but incorrect information
- You need domain knowledge to evaluate code quality
- Later, focus on building your own problem-solving skills
Resources
Key Points
- Use
help()or?to get online help in R - Use
??for fuzzy searches when you don’t know the exact function name - R help files provide detailed documentation including usage, arguments, and examples
- CRAN Task Views can help you find packages for specific tasks
- When asking for help, provide reproducible examples and session information