0
votes

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.

1
do you have #' @export on all your functions?SymbolixAU
No, Just on the first one, but the first one is using all the other functions.Thomas
What do you mean by "I get all the functions that are in my code instead"? Are all your functions in the NAMESPACE, or just those you've imported?SymbolixAU
So I have one main function that I want visible when someone load the package. This particular function is tagged with the #' @export. Then I have 30 other functions that are used by the main function but that are not tagged with #' @export. Those are to be loaded with the package but I don't want them to be usable by the user.Thomas
Are you using RStudio to build the package? Do you have Build > Configure Build Tools > Generate Documentation with Roxygen > Configure > Install and Restart checked? (sometimes this gets reset)SymbolixAU

1 Answers

1
votes

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.