Hi all,

I ran into a strange error: I am trying to create a package skeleton for a
new source package from within a function. Objects that are created in this
function are to be included in my package, but for some reason, I get an
error message saying that these objects cannot be found.

Here is the code:
######
myfun <- function(pkgName,x){
  myenv <- new.env()
  apply(x, 1, function(row){
    assign(row[1], row[2], envir=myenv)
  })
 f <- function(x,y) x+y
 e <- rnorm(1000)
# browser()
 package.skeleton(name = pkgName, list=c("f","e", "myenv"))
  return(myenv)
}
x <- data.frame(keys = LETTERS[1:5], values = 1:5)
myfun("test", x)
######

And my sessionInfo:
> sessionInfo()
R version 2.6.1 (2007-11-26)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
>
I did not find anything referring to this problem in the help page, on the R
mailing list or wiki. Has anyone noticed this or can someone explain to me
why my objects cannot be found?

Many thanks in advance,
best wishes,

Tine

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to