Using 'require' package code to obtain datapackages on the fly in R -
i writing r package uses variety of bioconductor annotation data packages. specific data packages vary use-case. such, have function this:
if (!require(biocpack_name, character.only=t)) { source("https://bioconductor.org/bioclite.r") biocinstaller::bioclite(biocpack_name) require(biocpack_name , character.only=t) }
biocpack_name can several of ~30+ annotation data packages looked based on particular data being analysed. such, don't want have add each 'suggests' (im not sure work because error not package rather string specifying package). r cmd chk gives me error:
'library' or 'require' call not declared from: ‘biocpack_name’ 'library' or 'require' call ‘biocpack_name’ in package code.
how around this?
it's not error, warning. goes away if use character.only = true
rather t
(i guess because value of true known , cannot re-assigned, t unknown , can anything, including false). in addition follow advice in warning use requirenamespace()
(and not pollute user search path); maybe db = get(biocpack_name, getnamespace(biocpack_name))
allow use annotation package way you'd like, e.g., mapids(db, ...)
.
if 1 pedantic, adding packages enhances: field of description file communicate package somehow works annotation packages, not result in installation of package (e.g., building vignette) unless explicitly requested.
Comments
Post a Comment