Ulrike Grömping
2013-Sep-06 09:36 UTC
[Rd] Importing function that is previously imported by other package
Dear developeRs, I encounter the following problem: in the current version of my package FrF2, certain calls to a functioni do not work when package combinat is loaded, because function combn from combinat masks the function from utils that my package uses. I tried to solve this issue by importing function combn into the namespace of FrF2; I don't need to export it, I just want to use it internally in the package; I could of course find all occurrences and replace them with utils::combn, but I thought that the namespace solution would be more elegant, faster, and in the spirit of R programming. The fix was successful: the installed package works with combinat on the search path. However, when installing or loading the modified FrF2, I now get the warning "replacing previous import by utils::combn when loading 'FrF2'" (that's on R-devel, on production R the wording is slightly different, but there is also a warning). There is no warning from R CMD check, however. In case this is relevant: None of the packages in my "Depends" list mentions "utils" under depends, one of the packages FrF2 depends on also imports from utils, including utils::combn. Shouldn't it be possible to have several packages IMport a function of the same name without a warning? Best, Ulrike -- ############################################## ## Prof. Dr. Ulrike Groemping ## FB II ## Beuth University of Applied Sciences Berlin ############################################## ## prof.beuth-hochschule.de/groemping ## Phone: +49(0)30 4504 5127 ## Fax: +49(0)30 4504 66 5127 ## Home office: +49(0)30 394 04 863 ##############################################
Duncan Murdoch
2013-Sep-06 10:53 UTC
[Rd] Importing function that is previously imported by other package
On 13-09-06 5:36 AM, Ulrike Gr?mping wrote:> Dear developeRs, > > I encounter the following problem: in the current version of my package > FrF2, certain calls to a functioni do not work when package combinat is > loaded, because function combn from combinat masks the function from > utils that my package uses. > I tried to solve this issue by importing function combn into the > namespace of FrF2; I don't need to export it, I just want to use it > internally in the package; I could of course find all occurrences and > replace them with utils::combn, but I thought that the namespace > solution would be more elegant, faster, and in the spirit of R > programming. The fix was successful: the installed package works with > combinat on the search path. > > However, when installing or loading the modified FrF2, I now get the > warning "replacing previous import by utils::combn when loading 'FrF2'" > (that's on R-devel, on production R the wording is slightly different, > but there is also a warning). There is no warning from R CMD check, > however. In case this is relevant: None of the packages in my "Depends" > list mentions "utils" under depends, one of the packages FrF2 depends on > also imports from utils, including utils::combn. > > Shouldn't it be possible to have several packages IMport a function of > the same name without a warning? > > Best, Ulrike >I think we need to see the details. I don't get those warnings with the version on CRAN. Perhaps you are importing it twice, e.g. import(combinat) importFrom(utils, combn) ? Duncan Murdoch