[R] building a package that contains S4 classes and methods
Marie Pierre Sylvestre
MP.Sylvestre at epimgh.mcgill.ca
Tue Sep 9 22:33:36 CEST 2008
Hello R users,
I am trying to make a my first package and I get an error that I can
understand. The package is build out of three files (one for functions, 1
for s4 classes and 1 for s4 methods).
Once I source them I run
package.skeleton( name="TDC" )
within a R session and I get
Creating directories ...
Creating DESCRIPTION ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './TDC/Read-and-delete-me'.
Warning messages:
1: In dump(internalObjs, file = file.path(code_dir,
sprintf("%s-internal.R", :
deparse of an S4 object will not be source()able
2: In dump(internalObjs, file = file.path(code_dir,
sprintf("%s-internal.R", :
deparse of an S4 object will not be source()able
3: In dump(internalObjs, file = file.path(code_dir,
sprintf("%s-internal.R", :
deparse of an S4 object will not be source()able
4: In dump(internalObjs, file = file.path(code_dir,
sprintf("%s-internal.R", :
deparse may be incomplete
I keep going in spite of the warnings with
R CMD check --no-examples TDC
and I get
* checking for working pdflatex ... OK
* using log directory
'/home/mariepierre/Packages/PermAlgo/PermAlgo/PermAlgo2/TDC.Rcheck'
* using R version 2.7.1 (2008-06-23)
* using session charset: UTF-8
* checking for file 'TDC/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'TDC' version '1.0'
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking whether package 'TDC' can be installed ... ERROR
Installation failed.
The error file says:
* Installing *source* package 'TDC' ...
** R
** preparing package for lazy loading
Error in parse(n = -1, file = file) : unexpected '<' at
102: `.__C__BindArgs` <-
103: <
Calls: <Anonymous> -> code2LazyLoadDB -> sys.source -> parse
Execution halted
ERROR: lazy loading failed for package 'TDC'
** Removing
'/home/mariepierre/Packages/PermAlgo/PermAlgo/PermAlgo2/TDC.Rcheck/TDC'
The problem is with my classes and methods. The respective files contain:
setClass("BindArgs", signature( "function" ))
setClass("BindArgs2", signature( "function" ))
and
setMethod("initialize", "BindArgs", function( .Object, f, ... )
callNextMethod( .Object, function( x ) f( x, ... ) ))
setMethod("initialize", "BindArgs2", function( .Object, f, ...)
callNextMethod( .Object, function( x, y ) f( x, y, ... ) ))
Everything works well within a R session but I can build the package.
If I look at the internal R file that this created I get
`.__C__BindArgs` <-
<S4 object of class structure("classRepresentation", package = "methods")>
`.__C__BindArgs2` <-
<S4 object of class structure("classRepresentation", package = "methods")>
`.__M__initialize:methods` <-
<S4 object of class structure("MethodsList", package = "methods")>
`.__T__initialize:methods` <-
<environment>
Well, let just say that I am new to classes so this confuses me greatly. I
have checked the documentation and tried a few things but I reached my
personal limits!
I am using R 2.7.1 on Linux Fedora 8.
Any comments on what is happening and/or help would be greatly appreciated.
MP
More information about the R-help
mailing list