message("TESTING: Package...")


# By defining .onAttach() as follows in zzz.R for a package, an
# instance of class Package with the same name as the package will
# be made available on the search path. More over, the code below
# will also inform the user that the package has been loaded:
#  > library(R.oo)
#  R.oo v0.52 (2003/04/13) was successfully loaded.
.onAttach <- function(libname, pkgname) {
  pkg <- Package(pkgname)
  assign(pkgname, pkg, pos=getPosition(pkg))
  cat(getName(pkg), " v", getVersion(pkg), " (", getDate(pkg), ")",
    " was successfully loaded.\n", sep="")

# The Package class works for any packages, loaded or not.

# Some information about the base package
pkg <- Package("base")
# [1] "Package: base v1.6.2 (NA) is loaded (pos=5). The official webpage
#      is NA and the maintainer is R Core Team <[email protected]>. The
#      package is installed in c:/PROGRA~1/R/rw1062/library/base/."

# Some information about the R.oo package
# [1] "Package: R.oo v0.52 (2003/04/13) is loaded (pos=2). The official
#      webpage is http://www.braju.com/R/ and the maintainer is Henrik
#      Bengtsson <[email protected]>. The package is installed in
#      c:/PROGRA~1/R/rw1062/library/R.oo/."

pkg <- Package("R.oo")
classes <- getClasses(pkg)
stopifnot(all(c("Object", "Class", "Interface", "Exception", "Package") %in% classes))

pkg <- Package("R.oo")
res <- showDescriptionFile(pkg, pager=function(...) TRUE)
res <- showNews(pkg, pager=function(...) TRUE)
res <- showChangeLog(pkg, pager=function(...) TRUE)
res <- showHistory(pkg, pager=function(...) TRUE)

res <- try(Package("Non-Existing-Package"), silent=TRUE)
stopifnot(inherits(res, "try-error"))

message("TESTING: Package...DONE")

Try the R.oo package in your browser

Any scripts or data that you put into this service are public.

R.oo documentation built on April 22, 2018, 9:03 a.m.