Adapted from Software Carpentry
Questions:
Objectives:
Access help for any function:
Help pages include: Description, Usage, Arguments, Details, Value, See Also, and Examples.
For special operators, use quotes or backticks:
Running Examples
Highlight code examples in help pages and hit Ctrl+Return to run them in RStudio.
Packages often include tutorials and extended examples:
See RStudio cheatsheets for common packages.
Search for functions when you don’t know the exact name:
CRAN Task Views organizes packages by topic.
[r] tagWhen asking for help, provide:
Tools like ChatGPT can provide helpful suggestions. However:
Challenge 1: Understanding the c Function
Look at the help page for the c function. What kind of vector do you expect will be created if you evaluate the following:
Solution to Challenge 1
The c() function creates a vector, and all elements of a vector must be the same type. In the first two cases, the elements are already the same type. But in the third case, R will convert all the numbers to characters to make them all the same type.
Challenge 2: Understanding paste
Look at the help for the paste function. You will need to use it later. What’s the difference between the sep and collapse arguments?
Solution to Challenge 2
sep controls how elements are separated within a single call to paste, while collapse controls how multiple results are combined into a single string.
Challenge 3: Finding Functions for Reading Data
Use help to find a function (and its associated parameters) that you could use to load data from a tabular file in which columns are delimited with “ (tab) and the decimal point is a”.” (period). This check for decimal separator is important, especially if you are working with international colleagues, because different countries have different conventions for the decimal point (i.e. comma vs period).
Hint: use ??"read table" to look up functions related to reading in tabular data.
Solution to Challenge 3
help() or ? to get online help in R?? for fuzzy searches when you don’t know the exact function name