简体   繁体   中英

Function exporting with Roxygen2 is exporting all the functions in my code instead of the one I want

I am building my own package for the first time and it is finally building with no problems. The problem is that I am exporting only one function with Roxygen2 (6.0.1) as it is the only one to be used but when I build and load my package, all the function present in it are exported. (When I look with package:: )

I've been searching for similar occurrences but didn't find any

Here is the Roxygen comments just before the function:

#' Do a plot
#'
#' @param region a GRange object with chr, start, end
#' @param genome a character vector "hg19","hg38" or "mm10"
#' @param BAM a path to the BAM related csv input file
#' @param BED a path to the BED related csv input file
#' @param avgTrack a logical indicating if the average track should be present or not
#' @param geneTrack a logical indicating if the gene track should be present or not
#' @param max a vector of number containing the maximum of each BAM track
#'
#' @export
myfunction <- function(){}

And here is the NAMESPACE that is generated by Roxygen2:

# Generated by roxygen2: do not edit by hand

export(myfunction)
importFrom(GenomicRanges,findOverlaps)
importFrom(IRanges,elementNROWS)
importFrom(IRanges,splitAsList)
importFrom(S4Vectors,List)
importFrom(S4Vectors,queryHits)
importFrom(S4Vectors,subjectHits)
importFrom(S4Vectors,subjectLength)
importFrom(biomaRt,getBM)
importFrom(grDevices,hcl)
importFrom(graphics,axis)
importFrom(graphics,legend)
importFrom(graphics,lines)
importFrom(graphics,par)
importFrom(graphics,plot)
importFrom(graphics,plot.new)
importFrom(graphics,rect)
importFrom(graphics,segments)
importFrom(graphics,text)
importFrom(rbamtools,bamCount)
importFrom(rbamtools,bamReader)
importFrom(rbamtools,getRefCoords)
importFrom(utils,read.table)

when I do mypackage:: I should have only one function showing (mypackage::myfunction) by I get all the functions that are in my code instead.

So for some reasons when I modify my NAMESPACE from export(myfunction) to export("myfunction") I get the expected result.

It can also be achieved by using #' @export "myfunction" with the Roxygen2 syntax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM