r - How to fix 'no item called "package:pkg" on the search list' without using library(pkg)? -
i writing package named testpkg , have put quantmod in depends section of description file.
i have written following functions:
#' hello1 #' #' @return na #' @export hello1 <- function() { print("hello1!") quantmod::is.hlc("hello, world!") } #' hello2 #' #' @return na #' @export hello2 <- function () { x <- structure(c(25.85, 25.639999, 26.700001, 26.26, 26.92, 27.870001, 25.26, 25.52, 26.66, 25.610001, 26.85, 27.74, 26352700, 32512200, 64264600, 25.610001, 26.85, 27.74), .indexclass = "date", tclass = "date", .indextz = "utc", tzone = "utc", src = "yahoo", updated = structure(1437653990.9303, class = c("posixct", "posixt")), class = c("xts", "zoo"), index = structure(c(1167782400, 1167868800, 1167955200), tzone = "utc", tclass = "date"), .dim = c(3l, 6l), .dimnames = list(null, c("yhoo.open", "yhoo.high", "yhoo.low", "yhoo.close", "yhoo.volume", "yhoo.adjusted"))) print(x) quantmod::chartseries(x) }
now, when go project , run testpkg::hello1()
, output expected.
however, if run testpkg::hello2()
, can see x
printed plot not generated. error:
error in as.environment("package:quantmod") : no item called "package:quantmod" on search list
i know can fix calling library(quantmod)
before making call testpkg::hello2()
seems odd me testpkg::hello1()
can run error-free without calling library(quantmod)
. reason , there alternative way run testpkg::hello2()
without calling library(quantmod)
first?
Comments
Post a Comment