How to handle masking conflicts in R package the right way? -
How to handle masking conflicts in R package the right way? -
i wonder best way handle masking conflicts right way if conflicting packages not own packages. consider next example. work lot time series , typically function names quarter, year etc. used quite often. if load tis
, data.table
functionality of r depends on sequence packages loaded.
library(tis) library(data.table) # masks: between, month, quarter, year library(tsfame) # loads tsdbi con <- tsconnect("somefame.db") # next fails when data.table loaded after tis ts1 <- tsget("somekeyinyourdb",con)
and tsget tsdbi
bundle not work anymore. need fork bundle , implement ::
syntax? illustration might specific, question pretty general. more experienced users do?
edit: need state more clearly. problem don't have chance phone call function explicitly because tsget calling function should called explicitly , assumes there's tis.
edit2, adding phone call stack requested richie cotton:
tracing year(actualstart) on entry [[1]] tsget("kofbauindikator_total", con) [[2]] tsget("kofbauindikator_total", con) [[3]] .local(serids, con, ...) [[4]] getfame(serids[i], dbname[i], save = false, envir = parent.frame(), start = null, end = null, getdoc = false) [[5]] year(actualstart) [[6]] .dotrace((function () print(sys.calls()))(), "on entry") [[7]] eval.parent(exprobj) [[8]] eval(expr, p) [[9]] eval(expr, envir, enclos) [[10]] (function () print(sys.calls()))() error in as.posixlt.default(x) : not know how convert 'x' class “posixlt”
the phone call stack shows ambiguously named function, year
, called getfame
. getanywhere("getfame")
reveals found in fame
package.
packagedescription("fame")
reveals fame
depends upon tis
rather importing it, problem lies. advised here, it's thought email bundle maintainer (jeff hallman) request alter dependency import. may require bit of bundle reworking, may suggest short-term prepare of changing line
startyear <- as.integer(year(actualstart))
in getfame
to
startyear <- as.integer(tis::year(actualstart))
(there may other changes necessary.)
while await prepare maintainer, override function using assigninnamespace
. is, before load package, type
assigninnamespace( "getfame", function(sernames, db, connection = null, save = false, envir = parent.frame(), start = null, end = null, getdoc = true) { # fixed function definition tis::year }, "fame" )
r conflict
Comments
Post a Comment