What is roxygen2?
Roxygen2 dynamically inspects the objects that it’s documenting, so it can automatically add data that you’d otherwise have to write by hand. It abstracts over the differences in documenting S3 and S4 methods, generics and classes so you need to learn fewer details.
How do I import a package into R?
Open R via your preferred method (icon on desktop, Start Menu, dock, etc.) Click “Packages” in the top menu then click “Install package(s)”. Choose a mirror that is closest to your geographical location. Now you get to choose which packages you want to install.
What is export in Roxygen?
Exports. For a function to be usable outside of your package, you must export it. By default roxygen2 doesn’t export anything from your package. If you want an object to be publicly available, you must explicitly tag it with @export . Functions: export functions that you want to make available.
How do you add a Roxygen in R?
Inserting a skeleton – Do this by placing your cursor anywhere in the function you want to document and click Code Tools -> Insert Roxygen Skeleton (default keyboard shortcut Ctrl+Shift+Alt+R ).
What does @param do in R?
@param name description describes the function’s inputs or parameters. The description should provide a succinct summary of the type of the parameter (e.g., string, numeric vector) and, if not obvious from the name, what the parameter does.
Where do I download R packages?
The Comprehensive R Archive Network (CRAN) is the official R packages repository, with thousands of free R packages available. Most of them have been developed by Data Scientists, Statisticians, Professors and researchers.
How do I import a CSV file into R?
In RStudio, click on the Workspace tab, and then on “Import Dataset” -> “From text file”. A file browser will open up, locate the . csv file and click Open. You’ll see a dialog that gives you a few options on the import.
What does library () do in R?
library(help = somename) computes basic information about the package somename, and returns this in an object of class “packageInfo” . (The structure of this class may change in future versions.) When used with the default value ( NULL ) for lib. loc , the attached packages are searched before the libraries.
How do I document an R script?
Ten simple rules for documenting scientific software
- Write comments as you code.
- Include a README file with basic information.
- Version control your documentation.
- Use automated documentation tools.
- Write error messages that provide solutions or point to your documentation.
What does @export do in R?
This function exports a data frame or matrix into a file with file format based on the file extension (or the manually specified format, if format is specified). The output file can be to a compressed directory, simply by adding an appropriate additional extensiont to the file argument, such as: “mtcars.
How do you use Roxygen in RStudio?
There are four basic steps:
- Add roxygen comments to your . R files.
- Run devtools::document() (or press Ctrl/Cmd + Shift + D in RStudio) to convert roxygen comments to . Rd files.
- Preview documentation with? .
- Rinse and repeat until the documentation looks the way you want.
How do I add comments to Roxygen?
This isn’t exactly what you’re looking for. But you can add an ROxygen2 skeleton for a function by placing your cursor inside the function then pressing ctr+alt+shift+R . Then if you hit enter in the ROxygen2 codeblock it will automatically add the backtick.