By module I mean a package instaled using: R CMD INSTAL /path/
On Tue, 27 Jun 2017 10:06:16 +0200 Jakub Jankiewicz <jcu...@jcubic.pl> wrote: > Hi, > > I found this issue: > > when I have 3 modules: > > * AnalysisA > * AnalysisB > * AnalysisC > > I load all modules at the beginning from list of modules: > > analyses <- list('AnalysisA', 'AnalysisB', 'AnalysisC') > > for (module in analyses) { > library(module, character.only = TRUE) > } > > and I want to add a function isValid to each module, but I've added it only > for AnalysisB. When I run this code: > > # value <- <selected by user> > > flags <- sapply(analyses, function(module) { > namespace <- getNamespace(module) > tryCatch({ > isValid <- get("isValid", namespace) > isValid(value) > }, error = function(e) { > TRUE > }) > }) > > # show analyses > > analyses[flags] > > then when R call get for AnalysisA it throw error, for AnalysisB it > return function but for AnalysisC it return function from AnalysisB and > don't throw error. > > As a workaround instead of tryCatch I've used: > > if ("isValid" %in% ls(namespace)) { > isValid <- get("isValid", namespace) > isValid(value) > } else { > TRUE > } > > Is this a bug? Should this be reported? > > I'm using R 3.4.0 on windows. > > -- > Jakub Jankiewicz, Web Developer > http://jcubic.pl/me -- Jakub Jankiewicz, Web Developer http://jcubic.pl/me ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.