Dear all,

I have been trying to create an R package. This has been successfull until I
tried to define classes.

Currently, my procedure is the following:

Start R, load the function and class definition
>tmp <- function (x) {x}
>setClass("rpa", contains = "list", where=topenv(parent.frame()))

Use package skeleton to create directory structure:
>package.skeleton(name = "test",list=c("tmp"))

Edit man files, add test/NAMESPACE file with the following contents:
>export(tmp)
>exportClasses("rpa")

Use R CMD check and R CMD build to create tarball.
-> No error messages.

Start R, install the created package:
>install.packages("test_1.0.tar.gz",repos=NULL)

Test the new package:
>require(test)
>my.object = new("rpa")

This gives the error message
>Error in getClass(Class, where = topenv(parent.frame())) :
> "rpa" is not a defined class

Any tips on how to define and export global classes in package creation?

I also tried
- to replace the 'topenv(parent.frame())' with '.GlobalEnv' in setClass.
- place the setClass within function 'tmp'
- exportClasses(rpa) in the namespace (without suffixes "")

I paged through the related mailing list discussions but could not find a
solution. Any tips and tricks would be worthwhile now; I guess this should
be a standard issue but it seems a bit tricky to come up with a quick
solution with the little programming experience that I have.

kind regards
Leo Lahti

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