Does roxygen2 automatically write NAMESPACE directives for Imports: packages?
Expanding on my comment, if you want to automatically add namespace
directives for packages/functions you import
, you can do so by adding the @imports package
or @importFrom package function
line to the roxygen2
documentation header of your function.
However, as @hadley pointed out, it will only modify the NAMESPACE
, but not affect the package DESCRIPTION
R: roxygen2, imported packages do not appear in namespace
If your file only contains the lines that you provided, it is ignored by roxygen2. You should add a line after the roxygen code that contains just NULL
. So the following should work:
#' @import reshape2 ggplot2 DESeq2 geneplotter
#' @import survcomp gplots pheatmap RColorBrewer
NULL
I have also reduced the number of lines to show you, how several packages can be imported with a single use of @import
. But it does not matter for roxygen, on how many lines you distribute the packages.
I think the reason for this is that the roxygen sections must be associated with some R object. For example, the documentation of a function is associated with the corresponding function object. Since you don't want to have the imports associated with a function, you can associate them with NULL
, which is an R object as well.
As hadley rightly points out, it is not recommended to fully import that many packages because you might end up with name conflicts. The following two alternatives are usually better:
Reference function with their explicit package name and the
::
operator:reshape2::melt()
This has the added advantage that you immediately see, from which package a function comes.Import only the functions that you need from a package using
@importFrom
:#' @importFrom reshape2 melt cast
You can find more information here.
Related Topics
Grouping & Visualizing Cumulative Features in R
Replacing All Missing Values in R Data.Table with a Value
Ggplot Geom_Point() with Colors Based on Specific, Discrete Values
Alternatives to Nested Ifelse Statements in R
Aesthetics Must Either Be Length One, or the Same Length as the Dataproblems
Check If Each Row of a Data Frame Is Contained in Another Data Frame
Mutating Column in 'Dplyr' Using 'Rowsums'
Replace Character at Certain Location Within String
Split Date Data (M/D/Y) into 3 Separate Columns
Use Fortran Subroutine in R? Undefined Symbol
Working with Dictionaries/Lists to Get List of Keys
How to Extract Fitted Splines from a Gam ('Mgcv::Gam')
Clipping Raster Using Shapefile in R, But Keeping the Geometry of the Shapefile
Ggplot2 - Multi-Group Histogram with In-Group Proportions Rather Than Frequency
Figure Captions, References Using Knitr and Markdown to HTML
Implementation of Parallel Coordinates
How to Create Binned Factor Variables from a Continuous Variable, with Custom Breaks