Hi Duncan,

Thank you very much for your explanations.

I have two doubts:

1) About this:










*>> The method I use is the following: >> >> >> rm(list=ls()) >> >>
setwd("D:/probando") >> >> source("probando.r", encoding="utf-8") >> >>
package.skeleton(name="ChrL", path="D:/probando")*

This says that you read the file d:/probando/probando.r, then created a
package in the same directory.  Don't do that.  Create the package
somewhere else, and copy the source to your functions into the R
subdirectory that gets created.

Am I using a wrong method for packaging? If I have source in "probando.r"
file, I think I have to load it (with source) and then I have to run
package.skeleton. How do I construct the pkg then?. I have read Writing R
Extensions and I thank I was right.


2) Abou this:













*> >> >> My Namespace: >> >> export(ChrL.Start) >> >> >> My
ChrL-internal.R: >> >> .ChrL.env <- new.env() As far as I can see, you
never added this to the package, so the environment wouldn't be created.*

Really I added it to the package (in folder created by package.skeleton)
and then I run "R CMD INSTALL ...", "R CMD check ...", "R CMD build ...",
"R CMD INSTALL --build ...". Then I load the zip in RGUI and I do
"library(ChrL)", but .ChrL.env does not exist.

Could you tell to me what I am doing in the wrong way?.

Thank you in advance.

Eva



2014-07-07 22:49 GMT+02:00 Duncan Murdoch <murdoch.dun...@gmail.com>:

> On 07/07/2014, 2:02 PM, Eva Prieto Castro wrote:
> > Hi eveybody,
> >
> > I think the problem is with the package.skeleton function, because of the
> > changes made in version 3.0.2. Since that version the management of
> > environment parameter is different and I think it can justify the fact of
> > package.skeleton is not considering my environment. I have not tested it
> > yet.
>
> The package.skeleton() function is intended to be used once as a quick
> setup of a new package; you shouldn't be using it routinely.  After the
> first quick setup, you should edit the source of the package to get what
> you want.
>
> A few more comments inline...
>
> >
> > Regards.
> >
> > Eva
> >
> >
> > 2014-07-07 10:21 GMT+02:00 Eva Prieto Castro <evapcas...@yahoo.es>:
> >
> >> Hi everybody
> >>
> >> I have a very big problem:
> >>
> >> With R 3.0.2 I could construct the package for this code:
> >>
> >>
> >> if (exists('.ChrL.env') == TRUE) {
> >>   rm(.ChrL.env)
> >> }
>
> The code above doesn't make sense in a package:  either you created the
> environment, or you didn't.  That code will look through attached
> packages, and if one of them has a variable of that name, will try to
> remove it (but will likely fail to do so).
>
> >>
> >> .ChrL.env <- new.env()
> >> .ChrL.env$lGlo <- list()
> >> .ChrL.env$bStarted <- FALSE
> >>
> >> CheckGloCreated <- function() {
> >>   if (.ChrL.env$bStarted == TRUE) {
> >>     stop("Data structures were already initialized.", call.=FALSE)
> >>   }
> >> }
> >> ChrL.Start <- function() {
> >>   CheckGloCreated()
> >>
> >>   cat("Libraries have been loaded and data structure has been
> >> initialized.\n")
> >> }
> >>
> >>
> >>
> >> As you can do, I used an own environment (.ChrL.env).
> >>
> >>
> >> Now, with R 3.1.0, I construct the package and I load it but it seems
> >> .ChrL.env does not exists.
> >>
> >>
> >> The method I use is the following:
> >>
> >>
> >> rm(list=ls())
> >>
> >> setwd("D:/probando")
> >>
> >> source("probando.r", encoding="utf-8")
> >>
> >> package.skeleton(name="ChrL", path="D:/probando")
>
> This says that you read the file d:/probando/probando.r, then created a
> package in the same directory.  Don't do that.  Create the package
> somewhere else, and copy the source to your functions into the R
> subdirectory that gets created.
>
> >>
> >>
> >> My Namespace:
> >>
> >> export(ChrL.Start)
> >>
> >>
> >> My ChrL-internal.R:
> >>
> >> .ChrL.env <- new.env()
>
> As far as I can see, you never added this to the package, so the
> environment wouldn't be created.
>
> Duncan Murdoch
>
> >>
> >>
> >> Could you help me, please?. It is very urgent...
> >>
> >>
> >> My project is more complex that the example I put, but I have tested
> with
> >> this simple example and the problem is the same.
> >>
> >>
> >> Thank you in advance.
> >>
> >>
> >> Regards,
> >>
> >> Eva
> >>         [[alternative HTML version deleted]]
> >>
> >>
> >> _______________________________________________
> >> R-help-es mailing list
> >> r-help...@r-project.org
> >> https://stat.ethz.ch/mailman/listinfo/r-help-es
> >>
> >>
> >
> >       [[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.
> >
>
>

        [[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