Skip to content

Problem with Rcmd check and S4 methods

7 messages · Duncan Murdoch, John Chambers

#
In the little orientation data package I'm working on, the very first
example fails, even though the same code works when used in a regular
session.  In my experience, this usually indicates T or F has been
used instead of TRUE or FALSE, but that's not the case this time.

The error message is

 > x <- eulerzyx(1,0,0)
 Error: Trying to get slot "validity" from an object of a basic class
("NULL") with no slots
 Execution halted

What I think is the relevant source looks like this:

setClass('orientation')
setIs('orientation','vector')

setClass('eulerzyx', representation(x = 'matrix'))
setIs('eulerzyx', 'orientation')

eulerzyx <- function(psi, theta, phi) 
    new('eulerzyx', x = cbind(psi, theta, phi))

Can anyone tell me what that error message means?  Is it something
I've done wrong, or a problem with the methods package or the checks?

Duncan Murdoch
#
Duncan Murdoch wrote:
The code has a NULL object that was supposed to be a class definition
(and therefore to have a "validity" slot).
I was able to add your source & the one-line example to a small package
and get through R CMD check.

Can you do example(eulerzyx) after attaching the package?

Are you using a saved image (e.g., with an empty install.R file in the
package directory)?  (Though if not, the check would often fail at an
earlier stage.)

It would be nice to be able to get a dump from the R CMD check
evaluation--maybe someone can suggest how.

John

  
    
#
On Fri, 13 Jun 2003 13:18:23 -0400, John Chambers wrote:

            
This is actually in the eulerzyx-class.Rd help file; I should have
said that.
I don't think so...

If you want to take a look, I've put the whole library (in its current
incomplete state) online at
<http://www.stats.uwo.ca/faculty/murdoch/temp/orientlib_1.0.tar.gz>,
and the log from running the examples here:
<http://www.stats.uwo.ca/faculty/murdoch/temp/orientlib-Ex.Rout>.


Duncan Murdoch
#
On Fri, 13 Jun 2003 13:18:23 -0400, you wrote:

            
If I just cut all the preamble from the Rout file and paste it into
the console, I get the same error.  Here's a traceback(), I'm not sure
what you mean by a dump.

Duncan
Error: Trying to get slot "validity" from an object of a basic class
("NULL") with no slots
5: validObject(.Object)
4: initialize(value, ...)
3: initialize(value, ...)
2: new("eulerzyx", x = cbind(psi, theta, phi))
1: eulerzyx(1, 0, 0)
#
Duncan Murdoch wrote:
I think the problem is from not using a saved image.  Using your tar
file, if I untar into orientlib/, I get the same error you report.  But
after creating the install.R file:

guinan[RPackages]$ touch orientlib/install.R

the error in this example goes away.  (There is a later error:
Error: ncol(m) == 9 is not TRUE

but I'm guessing this may be more local :-)

Hopefully for 1.8 we will get rid of the differences between saved image
and ordinary loading (except that the latter will still be slower for
packages doing much with classes and methods).

John
#
On Fri, 13 Jun 2003 15:04:44 -0400, you wrote:

            
Thanks, that fixed it.  Perhaps the check script could try to
determine if this was necessary?
Yes :-).

Duncan
#
Duncan Murdoch wrote:
It's a little tricky, and in any case the better solution is to ensure
that the semantics are the same with or without the saved image.

If it turns out that the time penalty for library(foo) with no saved
image is very large when foo contains class/method code, we could give a
warning at INSTALL time if a saved image is not created.  Or perhaps
make saved images the default?

John