I want to include PyTorch as a requirement for an R library using the reticulate -package.
(Another solution would be if it is installed (i.e., reticulate::py_install("PyTorch") ) when the user is using the library/function the first time, but not every time.)
I tried to add PyTorch as a dependence through the "header"/"description" of the function:
#' @importFrom reticulate PyTorch
But when I run devtools::document() I get this error:
Loading rpackageX Error in asChar(ivars) : empty name in directive 'importFrom' in 'NAMESPACE' file
The reticulate package has a vignette titled Managing an R Package’s Python Dependencies. It describes how you can list Python packages in a special field called Config/reticulate, which directs reticulate to automatically install these Python packages.
The tensorflow R package uses reticulate to wrap the tensorflow Python package. It does the following: