Hi All, I am working on a package BondLab for the analysis of fixed income securities. Building the package results in the following: Error in loadNamespace(package, c(which.lib.loc, lib.loc)) : cyclic namespace dependency detected when loading ?BondLab?, already loading ?BondLab? It occurs when I set the generic for the function mortgagecashflow. Further if a function uses mortgagecashflow, similarly its generic, when set, causes the above error. Other generics do not throw this error so I am quite sure it is mortgagecashflow. The package and the code can be found on github. https://github.com/glennmschultz/BondLab.git I have been trying to figure this out for a couple of months to no avail. If anyone has familiarity with this issue I would certainly appreciate any help with the issue. Thanks, Glenn
On 11/30/2014 07:15 AM, Glenn Schultz wrote:> Hi All, > > I am working on a package BondLab for the analysis of fixed income securities. Building the package results in the following: > > Error in loadNamespace(package, c(which.lib.loc, lib.loc)) : > cyclic namespace dependency detected when loading ?BondLab?, already loading ?BondLab? > > > It occurs when I set the generic for the function mortgagecashflow. Further if a function uses mortgagecashflow, similarly its generic, when set, causes the above error. Other generics do not throw this error so I am quite sure it is mortgagecashflow. The package and the code can be found on github. > https://github.com/glennmschultz/BondLab.git > > I have been trying to figure this out for a couple of months to no avail. If anyone has familiarity with this issue I would certainly appreciate any help with the issue. >Hi Glenn -- The root of the problem is that you are defining both a generic and a plain-old-function named MortgageCashFlow -- one or the other and you're fine. R CMD INSTALL pkgA, where pkgA contains a single R file R/test.R setGeneric("foo", function(x, ...) standardGeneric("foo")) foo <- function(x, ...) {} also generates this; maybe you meant something like .foo <- function(x, ...) {} setGeneric("foo", function(x, ...) standardGeneric("foo"), useAsDefault=".foo") or simply reversing the order of the declarations foo <- function(x, ...) {} setGeneric("foo", function(x, ...) standardGeneric("foo")) ? Martin Morgan> Thanks, > Glenn > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793
On 30/11/2014, 10:15 AM, Glenn Schultz wrote:> Hi All, > > I am working on a package BondLab for the analysis of fixed income securities. Building the package results in the following: > > Error in loadNamespace(package, c(which.lib.loc, lib.loc)) : > cyclic namespace dependency detected when loading ?BondLab?, already loading ?BondLab? > > > It occurs when I set the generic for the function mortgagecashflow. Further if a function uses mortgagecashflow, similarly its generic, when set, causes the above error. Other generics do not throw this error so I am quite sure it is mortgagecashflow. The package and the code can be found on github. > https://github.com/glennmschultz/BondLab.git > > I have been trying to figure this out for a couple of months to no avail. If anyone has familiarity with this issue I would certainly appreciate any help with the issue. >I don't see why this would cause the error you saw, but when I look at your DESCRIPTION file, I see: Depends: termstrc, reshape2, ggplot2, lubridate, methods, plyr, grid, optimx It's a good idea to strongly limit the number of "Depends" entries. Each of those potentially causes a change to the user's search list, and may break something. It's much better to use "Imports" instead, because that makes the other packages available to you, but doesn't put them in the search list. Duncan Murdoch