Why does my package function not find other functions not related to export?

I read most of Hadley Wickham's book: http://r-pkgs.had.co.nz/ , but I am confused why my functions in my package cannot find my other non-exported functions.

For example, I have

#' @export
#' @import ggmap
#' @import hexbin
map  <- function(return.query, zoom, maptype, histObj) {

  UseMethod("map")

}
#' 
map.querySold  <- function(query, zoom = 11, maptype = "roadmap") {
  My Code
}

Running this with a clean environment and downloading my package causes an error:

> map(x) # x is of class querySold
Error in UseMethod("map") : 
  no applicable method for 'map' applied to an object of class "c('querySold', 'data.frame')"

What is wrong and how can I fix it? I thought that internal functions are always available for all other functions inside the package? Until I load all the functions with devtools::load_all("."), it works.

+4
source share
1 answer

I suspect you do not @export map.querySold. Try the following:

@export map.

#' @import ggmap
#' @import hexbin
#' @export
map  <- function(return.query, zoom, maptype, histObj) {

  UseMethod("map")

}

@export

#'@export 
map.querySold  <- function(query, zoom = 11, maptype = "roadmap") {
  My Code
}

devtools::document() NAMESPACE.

, NAMESPACE. ,

S3method(map.querySold)
export(map)
+2

All Articles