Can I generate comments using roxygen2 without building an R package? [duplicate] - r

This question already has answers here:
Possible to create Rd help files for objects not in a package?
(7 answers)
Closed 7 years ago.
I need to generate documentation for a collection of R programs. Unfortunately, building a package based on the source code is not an option (I know how to do that, and I have already experimented with RStudio, roxygen2, and packages, and it works like a charm). Can I use roxygen2 to to generate documentation from the R source code without building a package in a way similar to how doxygen works with C++? If not, are there other options for documenting R code that do not rely on packages?

If your only after the documentation, devtools::document() will build the documentation files without building the package.

Related

ERROR: Could not find function "write.xlsx" [duplicate]

This question already has answers here:
Error: could not find function ... in R
(10 answers)
Closed 10 days ago.
I'm having real trouble running the function write.xlsx - the error "could not find function "write.xlsx"
I've already tried to:
Install the packages xlsx, readxl, writexl, XLConnect but no one of these is working.
Install Java JRE, but it's not working as well
Have you guys ever had a similar problem before?
I'm really needing to start running those flows which are properly working in other machines.
PS: I'm a beginner in the R coding
After installing the package xlsx you should also load the library in order to use the function, like this:
library(xlsx)
If you're just going to use the function one time you can call it without loading the library first like this:
xlsx::write.xlsx(data, file = "file.xlsx")
Hope this helps

R Roxygen2 documentation without building a package

I am currently programming within an R project. Right now there is no need for building a whole package, but I would like to use roxygen to create documentation of several functions nonetheless.
Whenever I am looking for "object documentation" or "roxygen", the context is immediately package development (e.g. https://r-pkgs.org/man.html).
Is it possible to document the functions using roxygen without building a package?
Thanks a lot!

Is there a command in R to view all the functions present in a package? [duplicate]

This question already has answers here:
How to find all functions in an R package?
(6 answers)
Closed 7 years ago.
I would like to know if there is a command, using which one can view all the functions that are built into an R package.
For example, let's say I loaded a package into environment:
require(dplyr)
Now, I would like to get a list of all the functions present in the dplyr package.
Is there any way to get such a list?
You can use lsf.str.
For instance:
lsf.str("package:dplyr")
To list all objects in the package use ls
ls("package:dplyr")
Note that the package must be attached.
To see the list of currently loaded packages use
search()
Alternatively calling the help would also do, even if the package is not attached:
help(package = dplyr)
Finally, you can use RStudio which provides an autocomplete function. So, for instance, typing dplyr:: in the console or while editing a file will result in a popup list of all dplyr functions/objects.

Make third party library available in my R package [duplicate]

This question already has answers here:
Regular expression to match a line that doesn't contain a word
(34 answers)
Better explanation of when to use Imports/Depends
(4 answers)
Closed 4 years ago.
I am developing an R package that uses third party functions
available in the Bioconductor package "methyilumi"
In the code for my R package at the very beginning I import methylumi
with library(methylumi).
During the development (I use roxygen2 and devtools) everything works fine.
However, when I install the package and run my functions, I get the error:
could not find function "methylumIDAT".
Of course everything is solved if I import the package manually, but how can I make
so that methylumi is available whenever I load my own package?
Since you are using devtools, you can add
devtools::use_package("methyilumi")
in the console, and call methyilumi::methylumIDAT in the body of your function. That way, the package is automatically listed in Imports in the DESCRIPTION file.
This sections gives the instructions for several different cases:
http://r-pkgs.had.co.nz/namespace.html#imports
This is done with the NAMESPACE file and also noted in the DESCRIPTION file. There are a few ways to import a function in NAMESPACE, but the simplest is just importFrom("[PACKAGE_NAME]",[FUNCTION_NAME). Then, in DESCRIPTION, add the package name to imports.
See this very good tutorial from Friedrich Leisch.
http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf

Building a package so that it loads other packages automatically in R [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to properly use functions from other packages in a R package
load data set automatically
I've built an R package and am now testing it. It requires several packages like scatterplot3d, gdata, etc.
How can I get those packages to load automatically, when someone loads my package?
Thanks!
Edit Re Comments: I've already set imports in the Description and I've set the namespaces file. I know this works because the examples I put in work when I do R CMD Check. However, if I just load up R, type library(mypackage) it gives me an error.
Edit: Solved, I moved the packages I had in the imports section to the depends section. Thank you!

Resources