Hi,

I'm trying to create a package that contains reference class
definitions from which users can create reference objects, but there
seems to be something awry.

My toy example creates an empty package via
package.skeleton('TestClass') to which I add the following R code:

TestClass <- setRefClass('TestClass',fields=c('name'))

Unfortunately my R console output bears this:

> library(TestClass)
> TestClass$new(name='foo')
Error: attempt to apply non-function
> getRefClass('TestClass')$new(name='foo')
Error: attempt to apply non-function

Creating the same reference class in the global environment works though:

> x <- setRefClass('TestClass',fields='name')
> x$new(name='foo')
An object of class "TestClass"
<environment: 0x82a43cc>

I'm new to S4 and reference classes, so maybe I'm missing something fundamental?

Jeff

> sessionInfo()
R version 2.13.0 Under development (unstable) (2011-02-02 r54197)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base

other attached packages:
[1] TestClass_1.0

loaded via a namespace (and not attached):
[1] tools_2.13.0

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to