[R] package.skeleton, environment argument causes error

Jacob Strunk strunky at gmail.com
Fri Aug 19 00:12:38 CEST 2016

Hello, I have been using package.skeleton from within an lapply statement
successfully (assuming good source code) with the following setup in the


but now fails with error:

Error: evaluation nested too deeply: infinite recursion /

I am working in RStudio Version 0.99.896, with 64 bit R version 3.3.1

I have been probing the code for package.skeleton a bit and noticed that
the default arguments for 'list' and 'environment' are supplied in the
function definition, thus making it impossible to achieve the conditions

missing(list) = TRUE

as a result of the fact that missing(list) cannot be true, the classesList
argument is empty and the call

classes0 <- .fixPackageFileNames(classesList)

then fails with the error

Error: evaluation nested too deeply: infinite recursion /

If I remove the default arguments I get further, but get the same error  I
had before (Error: evaluation nested too deeply: infinite recursion /
options(expressions=)?) after executing the following code:

methods0 <- .fixPackageFileNames(methodsList)

and the contents of methodsList look like

An object of class "ObjectsWithPackage":


the function .fixPackageFileNames fails when it reaches

list <- as.character(list)

where in this case the contents of 'list' look like

Formal class 'ObjectsWithPackage' [package "methods"] with 2 slots
  ..@ .Data  : chr(0)
  ..@ package: chr(0)

I am not sure if the problem arose from changes to package.skeleton
or methods::getClasses and methods::getGenerics or if there is something
peculiar about my environment.

my current ugly fix is to define the function .fixPackageFileNames in the
global environment and add a try statement and exit when it results in an
object of class "try-error":

function (list)
    list <- *try(*as.character(list)*)*
    if (length(list) == 0L)
    list0 <- gsub("[[:cntrl:]\"*/:<>?\\|]", "_", list)
    wrong <- grep("^(con|prn|aux|clock\\$|nul|lpt[1-3]|com[1-4])(\\..*|)$",
    if (length(wrong))
        list0[wrong] <- paste0("zz", list0[wrong])
    ok <- grepl("^[[:alnum:]]", list0)
    if (any(!ok))
        list0[!ok] <- paste0("z", list0[!ok])
    list1 <- tolower(list0)
    list2 <- make.unique(list1, sep = "_")
    changed <- (list2 != list1)
    list0[changed] <- list2[changed]

Any assistance with this error would be greatly appreciated!

Thank you,

Jacob Strunk
strunky at gmail.com

	[[alternative HTML version deleted]]

More information about the R-help mailing list