Re: [Rd] Problem with defining new method for residuals()

2011-03-11 Thread ONKELINX, Thierry
Dear Martin,

Thank you very much for your solution. It works fine.

Best regards,

Thierry


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie  Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics  Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data.
~ John Tukey
  

 -Oorspronkelijk bericht-
 Van: Martin Morgan [mailto:mtmor...@fhcrc.org] 
 Verzonden: vrijdag 11 maart 2011 7:36
 Aan: ONKELINX, Thierry
 CC: r-devel@r-project.org; John Chambers
 Onderwerp: Re: [Rd] Problem with defining new method for residuals()
 
 On 03/10/2011 08:21 AM, ONKELINX, Thierry wrote:
  Dear all,
  
  I'm writing a package and I would like to reuse the residuals() 
  function. When I use a function which calls the redefined residuals 
  (for my custom class) I get an error (see below). It looks like the 
  wrong method is used. The strange this is, that when it execute the 
  code manually it get no error.
 
 Hi Thierry --
 
 I think this is a bug in the methods package.
 
 Your package promotes stats::residuals to an S4 generic. 
 Normally this should work.
 
 However, your package Depends: on lme4, which also promotes 
 stats::residuals to an S4 generic. Apparently, this 
 interferes with your own attempt to make a generic, even 
 though you do not import lme4 into your name space. As a 
 consequence of the (putative) bug, your package sees the 
 original stats::residuals.
 
 A work-around seems to be to importFrom(lme4, residuals) and 
 do NOT import residuals from stats, so that your own method 
 is associated with the generic defined in lme4.
 
 Martin
 
  
  Any suggestions?
  
  Best regards,
  
  Thierry
  
  The entire source code is at
  svn://scm.r-forge.r-project.org/svnroot/aflp
  
  The code with the error.
  
  normalise(dummy)
  Error in object$na.action : $ operator not defined for this S4 class
  traceback()
  5: naresid(object$na.action, object$residuals) at normalise.R#30 4:
  residuals.default(outliers(data)) at normalise.R#30 3:
  residuals(outliers(data)) at normalise.R#30 2:
  nrow(residuals(outliers(data))) at normalise.R#30 1:
  normalise(dummy) #This works fine
  data - dummy nrow(residuals(outliers(data)))
  [1] 0
  
  NAMESPACE importFrom(stats, residuals, resid, hclust, princomp)
  exportPattern(.)
  
  METHODS setMethod(residuals, signature(object = AFLP.outlier), 
  function(object, ...){ object@Residual } )
  
  setMethod(resid, signature(object = AFLP.outlier), 
  function(object, ...){ object@Residual } )
  
  
 --
  --
 
  
 ir. Thierry Onkelinx
  Instituut voor natuur- en bosonderzoek team Biometrie  
 Kwaliteitszorg 
  Gaverstraat 4 9500 Geraardsbergen Belgium
  
  Research Institute for Nature and Forest team Biometrics  Quality 
  Assurance Gaverstraat 4 9500 Geraardsbergen Belgium
  
  tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be
  
  To call in the statistician after the experiment is done may be no 
  more than asking him to perform a post-mortem examination: 
 he may be 
  able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
  
  The plural of anecdote is not data. ~ Roger Brinner
  
  The combination of some data and an aching desire for an 
 answer does 
  not ensure that a reasonable answer can be extracted from a 
 given body 
  of data. ~ John Tukey
  
  __ 
 R-devel@r-project.org 
  mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
 
 
 --
 Computational Biology
 Fred Hutchinson Cancer Research Center
 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109
 
 Location: M1-B861
 Telephone: 206 667-2793
 
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Using missing() in a S4 method with extra arguments

2011-03-11 Thread Andreas Borg

Hi all,

I have a function which makes use of missing() to determine which 
arguments are provided in the call - basically, there are two sets of 
arguments that map to different strategies the function uses to fulfill 
its task. After conversion to an S4 generic I've run into the problem 
that if a method uses extra arguments that are not in the signature of 
the generic, usage of missing() fails. The following example exemplifies 
this:


   setGeneric(fun, function(x=0, y=0, ...) standardGeneric(fun))
   # both methods should output if the second argument is missing
   setMethod(fun, character, function(x=0, y=0, ...) missing(y))
   setMethod(fun, numeric, function(x=0, y=0, z=0, ...) missing(y))

   fun(a) # this works fine
   fun(1) # this gives FALSE

I've understood so far that this is due to the fact that the numeric 
method in this example is rewritten to:


   function (x = 0, y = 0, ...)
   {
   .local - function (x = 0, y = 0, z = 0, ...)
   missing(y)
   .local(x, y, ...)
   }

The call to .local evaluates y and it is no more missing.

Is there any alternative that works in this case? Or is there a chance 
that missing() might be changed to work in this case in the near future?


Of course I know I could set NA or NULL as default values and check for 
these, but there are reasons I want to have legal default values for all

arguments.

Best regards,

Andreas

Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


Re: [Rd] Using missing() in a S4 method with extra arguments

2011-03-11 Thread Martin Morgan
On 03/11/2011 02:07 AM, Andreas Borg wrote:
 Hi all,
 
 I have a function which makes use of missing() to determine which
 arguments are provided in the call - basically, there are two sets of
 arguments that map to different strategies the function uses to fulfill
 its task. After conversion to an S4 generic I've run into the problem
 that if a method uses extra arguments that are not in the signature of
 the generic, usage of missing() fails. The following example exemplifies
 this:
 
setGeneric(fun, function(x=0, y=0, ...) standardGeneric(fun))
# both methods should output if the second argument is missing
setMethod(fun, character, function(x=0, y=0, ...) missing(y))
setMethod(fun, numeric, function(x=0, y=0, z=0, ...) missing(y))
 
fun(a) # this works fine
fun(1) # this gives FALSE

Hi Andreas --

if you're testing for the missing-ness of y, and y is in the function
signature, then use that for dispatch

   setMethod(fun, c(character, missing),
 function(x=0, y=0, z=0, ...) missing)
   setMethod(fun, c(character, ANY),
 function(x=0, y=0, z=0, ...) not missing)

Since you're dispatching on x and y, it doesn't really make sense (to me
;) to assign default values to them. Testing for missing-ness of z would
I think have to rely on NA / NULL or other sentinel.

Martin
 
 I've understood so far that this is due to the fact that the numeric
 method in this example is rewritten to:
 
function (x = 0, y = 0, ...)
{
.local - function (x = 0, y = 0, z = 0, ...)
missing(y)
.local(x, y, ...)
}
 
 The call to .local evaluates y and it is no more missing.
 
 Is there any alternative that works in this case? Or is there a chance
 that missing() might be changed to work in this case in the near future?
 
 Of course I know I could set NA or NULL as default values and check for
 these, but there are reasons I want to have legal default values for all
 arguments.
 
 Best regards,
 
 Andreas
 
 Andreas Borg
 Medizinische Informatik
 
 UNIVERSITÄTSMEDIZIN
 der Johannes Gutenberg-Universität
 Institut für Medizinische Biometrie, Epidemiologie und Informatik
 Obere Zahlbacher Straße 69, 55131 Mainz
 www.imbei.uni-mainz.de
 
 Telefon +49 (0) 6131 175062
 E-Mail: b...@imbei.uni-mainz.de
 
 Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
 Informationen. Wenn Sie nicht der
 richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
 informieren Sie bitte sofort den
 Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die
 unbefugte Weitergabe
 dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

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


Re: [Rd] Using missing() in a S4 method with extra arguments

2011-03-11 Thread Andreas Borg

Hi Martin,

in the real function, I am not dispatching on the argument for which I 
test missingness, but it might be a good idea to do so - this way I 
could make the function tidier by relocating different branches to 
seperate methods. Thanks for the suggestion!


Andreas



if you're testing for the missing-ness of y, and y is in the function
signature, then use that for dispatch

   setMethod(fun, c(character, missing),
 function(x=0, y=0, z=0, ...) missing)
   setMethod(fun, c(character, ANY),
 function(x=0, y=0, z=0, ...) not missing)

Since you're dispatching on x and y, it doesn't really make sense (to me
;) to assign default values to them. Testing for missing-ness of z would
I think have to rely on NA / NULL or other sentinel.

Martin
  


--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


[Rd] hook for when R quits

2011-03-11 Thread Michael Lawrence
Hi,

Is there any way that a package can listen for when R quits? The Qt stuff is
hooking into platform-specific event loops and when those die unexpectedly
(from the perspective of Qt), it aborts, causing an annoying error dialog.
If we could catch when R is killed, we could cleanup, like we do with
.onUnload.

Thanks,
Michael

[[alternative HTML version deleted]]

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


Re: [Rd] hook for when R quits

2011-03-11 Thread Jeffrey Ryan
Take a look at reg.finalizer.  You'd have to create an object
internally that would persist until R exits - and a related function
to handle cleanup of course.

HTH
Jeff

On Fri, Mar 11, 2011 at 12:08 PM, Michael Lawrence
lawrence.mich...@gene.com wrote:
 Hi,

 Is there any way that a package can listen for when R quits? The Qt stuff is
 hooking into platform-specific event loops and when those die unexpectedly
 (from the perspective of Qt), it aborts, causing an annoying error dialog.
 If we could catch when R is killed, we could cleanup, like we do with
 .onUnload.

 Thanks,
 Michael

        [[alternative HTML version deleted]]

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




-- 
Jeffrey Ryan
jeffrey.r...@lemnica.com

www.lemnica.com

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


Re: [Rd] hook for when R quits

2011-03-11 Thread Michael Lawrence
Thanks for the suggestion, but I don't think that R finalizes all of its
objects when it quits. At least a simple test suggests that on Linux.

Michael

On Fri, Mar 11, 2011 at 10:19 AM, Jeffrey Ryan jeffrey.r...@lemnica.comwrote:

 Take a look at reg.finalizer.  You'd have to create an object
 internally that would persist until R exits - and a related function
 to handle cleanup of course.

 HTH
 Jeff

 On Fri, Mar 11, 2011 at 12:08 PM, Michael Lawrence
 lawrence.mich...@gene.com wrote:
  Hi,
 
  Is there any way that a package can listen for when R quits? The Qt stuff
 is
  hooking into platform-specific event loops and when those die
 unexpectedly
  (from the perspective of Qt), it aborts, causing an annoying error
 dialog.
  If we could catch when R is killed, we could cleanup, like we do with
  .onUnload.
 
  Thanks,
  Michael
 
 [[alternative HTML version deleted]]
 
  __
  R-devel@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-devel
 



 --
 Jeffrey Ryan
 jeffrey.r...@lemnica.com

 www.lemnica.com


[[alternative HTML version deleted]]

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


Re: [Rd] hook for when R quits

2011-03-11 Thread Henrik Bengtsson
See onSessionExit() in the R.utils package, e.g.

onSessionExit(function(...) {
  cat(Bye bye world!\n);
})

quit();

Please pay attention to the Details section of help(onSessionExit);
there are ways that R can exit that will not be detected/handled.

/Henrik

On Fri, Mar 11, 2011 at 10:37 AM, Michael Lawrence
lawrence.mich...@gene.com wrote:
 Thanks for the suggestion, but I don't think that R finalizes all of its
 objects when it quits. At least a simple test suggests that on Linux.

 Michael

 On Fri, Mar 11, 2011 at 10:19 AM, Jeffrey Ryan 
 jeffrey.r...@lemnica.comwrote:

 Take a look at reg.finalizer.  You'd have to create an object
 internally that would persist until R exits - and a related function
 to handle cleanup of course.

 HTH
 Jeff

 On Fri, Mar 11, 2011 at 12:08 PM, Michael Lawrence
 lawrence.mich...@gene.com wrote:
  Hi,
 
  Is there any way that a package can listen for when R quits? The Qt stuff
 is
  hooking into platform-specific event loops and when those die
 unexpectedly
  (from the perspective of Qt), it aborts, causing an annoying error
 dialog.
  If we could catch when R is killed, we could cleanup, like we do with
  .onUnload.
 
  Thanks,
  Michael
 
         [[alternative HTML version deleted]]
 
  __
  R-devel@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-devel
 



 --
 Jeffrey Ryan
 jeffrey.r...@lemnica.com

 www.lemnica.com


        [[alternative HTML version deleted]]

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


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


Re: [Rd] hook for when R quits

2011-03-11 Thread Duncan Murdoch

On 11/03/2011 1:37 PM, Michael Lawrence wrote:

Thanks for the suggestion, but I don't think that R finalizes all of its
objects when it quits. At least a simple test suggests that on Linux.


Did you use onexit=TRUE?  On Windows that appears to work...

Duncan Murdoch


Michael

On Fri, Mar 11, 2011 at 10:19 AM, Jeffrey Ryanjeffrey.r...@lemnica.comwrote:

  Take a look at reg.finalizer.  You'd have to create an object
  internally that would persist until R exits - and a related function
  to handle cleanup of course.

  HTH
  Jeff

  On Fri, Mar 11, 2011 at 12:08 PM, Michael Lawrence
  lawrence.mich...@gene.com  wrote:
Hi,
  
Is there any way that a package can listen for when R quits? The Qt stuff
  is
hooking into platform-specific event loops and when those die
  unexpectedly
(from the perspective of Qt), it aborts, causing an annoying error
  dialog.
If we could catch when R is killed, we could cleanup, like we do with
.onUnload.
  
Thanks,
Michael
  
   [[alternative HTML version deleted]]
  
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
  



  --
  Jeffrey Ryan
  jeffrey.r...@lemnica.com

  www.lemnica.com


[[alternative HTML version deleted]]

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


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


Re: [Rd] hook for when R quits

2011-03-11 Thread Prof Brian Ripley

On Fri, 11 Mar 2011, Duncan Murdoch wrote:


On 11/03/2011 1:37 PM, Michael Lawrence wrote:

Thanks for the suggestion, but I don't think that R finalizes all of its
objects when it quits. At least a simple test suggests that on Linux.


Did you use onexit=TRUE?  On Windows that appears to work...


It does work: RODBC makes extensive use of it, for exactly the purpose 
you describe (or rather, the C_level equivalent of 'it').




Duncan Murdoch


Michael

On Fri, Mar 11, 2011 at 10:19 AM, Jeffrey 
Ryanjeffrey.r...@lemnica.comwrote:


  Take a look at reg.finalizer.  You'd have to create an object
  internally that would persist until R exits - and a related function
  to handle cleanup of course.

  HTH
  Jeff

  On Fri, Mar 11, 2011 at 12:08 PM, Michael Lawrence
  lawrence.mich...@gene.com  wrote:
Hi,
  
Is there any way that a package can listen for when R quits? The Qt 
stuff

  is
hooking into platform-specific event loops and when those die
  unexpectedly
(from the perspective of Qt), it aborts, causing an annoying error
  dialog.
If we could catch when R is killed, we could cleanup, like we do with
.onUnload.
  
Thanks,
Michael
  
   [[alternative HTML version deleted]]
  
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
  



  --
  Jeffrey Ryan
  jeffrey.r...@lemnica.com

  www.lemnica.com


[[alternative HTML version deleted]]

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


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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [Rd] hook for when R quits

2011-03-11 Thread Henrik Bengtsson
On Fri, Mar 11, 2011 at 11:07 AM, Prof Brian Ripley
rip...@stats.ox.ac.uk wrote:
 On Fri, 11 Mar 2011, Duncan Murdoch wrote:

 On 11/03/2011 1:37 PM, Michael Lawrence wrote:

 Thanks for the suggestion, but I don't think that R finalizes all of its
 objects when it quits. At least a simple test suggests that on Linux.

 Did you use onexit=TRUE?  On Windows that appears to work...

Agree - here an object finalizer is more appropriate (different from
an end-of-session hook).


 It does work: RODBC makes extensive use of it, for exactly the purpose you
 describe (or rather, the C_level equivalent of 'it').

In help(reg.finalizer) it says:

  'onexit': logical: should the finalizer be run if the object is
still uncollected at the end of the R session?

What environments, objects, search path etc are available when the
finalizer is called this way when R exits?  Is safe to always add
'onexit=TRUE' (which now defaults to FALSE), or should I expect an
exceptional R system that the finalizer needs to account for?

Is there any further documentation on what happens when an R session
shuts down and in which order?

/Henrik



 Duncan Murdoch

 Michael

 On Fri, Mar 11, 2011 at 10:19 AM, Jeffrey
 Ryanjeffrey.r...@lemnica.comwrote:

   Take a look at reg.finalizer.  You'd have to create an object
   internally that would persist until R exits - and a related function
   to handle cleanup of course.
 
   HTH
   Jeff
 
   On Fri, Mar 11, 2011 at 12:08 PM, Michael Lawrence
   lawrence.mich...@gene.com  wrote:
     Hi,
   
     Is there any way that a package can listen for when R quits? The Qt
  stuff
   is
     hooking into platform-specific event loops and when those die
   unexpectedly
     (from the perspective of Qt), it aborts, causing an annoying error
   dialog.
     If we could catch when R is killed, we could cleanup, like we do
  with
     .onUnload.
   
     Thanks,
     Michael
   
            [[alternative HTML version deleted]]
   
     __
     R-devel@r-project.org mailing list
     https://stat.ethz.ch/mailman/listinfo/r-devel
   
 
 
 
   --
   Jeffrey Ryan
   jeffrey.r...@lemnica.com
 
   www.lemnica.com
 

        [[alternative HTML version deleted]]

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

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


 --
 Brian D. Ripley,                  rip...@stats.ox.ac.uk
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford,             Tel:  +44 1865 272861 (self)
 1 South Parks Road,                     +44 1865 272866 (PA)
 Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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


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


[Rd] WARNING Undocumented S4 methods 'initialize' - why?

2011-03-11 Thread cstrato

Dear all,

I am just writing the documentation file for S4 class 'QualTreeSet' and 
get the following warning with R CMD check:


* checking for missing documentation entries ... WARNING
Undocumented S4 methods:
  generic 'initialize' and siglist 'QualTreeSet'
All user-level objects in a package (including S4 classes and methods)
should have documentation entries.
See the chapter 'Writing R documentation files' in manual 'Writing R
Extensions'.

All my S4 classes have a method 'initialize' and R CMD check has never 
complained. Thus, do you have any idea why I get suddenly this warning 
for method 'initialize'?



Here is the code for 'QualTreeSet':

setClass(QualTreeSet,
   representation(qualtype = character,
  qualopt  = character
   ),
   contains=c(ProcesSet),
   prototype(qualtype = rlm,
 qualopt  = raw
   )
)#QualTreeSet

setMethod(initialize, QualTreeSet,
   function(.Object,
qualtype = rlm,
qualopt  = raw,
...)
   {
  if (qualtype == ) qualtype - rlm;
  if (qualopt  == ) qualopt  - raw;

  .Object - callNextMethod(.Object,
qualtype = qualtype,
qualopt  = qualopt,
...);
  .Object@qualtype = qualtype;
  .Object@qualopt  = qualopt;
  .Object;
   }
)#initialize


However, here is my code for a similar class 'ExprTreeSet' (which is the 
class from where I have copied the code):


setClass(ExprTreeSet,
   representation(exprtype = character,
  normtype = character
   ),
   contains=c(ProcesSet),
   prototype(exprtype = none,
 normtype = none
   )
)#ExprTreeSet

setMethod(initialize, ExprTreeSet,
   function(.Object,
exprtype = none,
normtype = none,
...)
   {
  if (exprtype == ) exprtype - none;
  if (normtype == ) normtype - none;

  .Object - callNextMethod(.Object,
exprtype = exprtype,
normtype = normtype,
...);
  .Object@exprtype = exprtype;
  .Object@normtype = normtype;
  .Object;
   }
)#initialize

In this case R CMD check does not complain, so why does it in the case 
of 'QualTreeSet'?


Here is my:
 sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C

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

other attached packages:
[1] xps_1.11.4

Thank you in advance
Best regards
Christian
_._._._._._._._._._._._._._._._._._
C.h.r.i.s.t.i.a.n   S.t.r.a.t.o.w.a
V.i.e.n.n.a   A.u.s.t.r.i.a
e.m.a.i.l:cstrato at aon.at
_._._._._._._._._._._._._._._._._._

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


Re: [Rd] hook for when R quits

2011-03-11 Thread Duncan Murdoch

On 11/03/2011 3:11 PM, Henrik Bengtsson wrote:

On Fri, Mar 11, 2011 at 11:07 AM, Prof Brian Ripley
rip...@stats.ox.ac.uk  wrote:
  On Fri, 11 Mar 2011, Duncan Murdoch wrote:

  On 11/03/2011 1:37 PM, Michael Lawrence wrote:

  Thanks for the suggestion, but I don't think that R finalizes all of its
  objects when it quits. At least a simple test suggests that on Linux.

  Did you use onexit=TRUE?  On Windows that appears to work...

Agree - here an object finalizer is more appropriate (different from
an end-of-session hook).


  It does work: RODBC makes extensive use of it, for exactly the purpose you
  describe (or rather, the C_level equivalent of 'it').

In help(reg.finalizer) it says:

   'onexit': logical: should the finalizer be run if the object is
still uncollected at the end of the R session?

What environments, objects, search path etc are available when the
finalizer is called this way when R exits?  Is safe to always add
'onexit=TRUE' (which now defaults to FALSE), or should I expect an
exceptional R system that the finalizer needs to account for?


To be very conservative, I would assume that nothing in R is available 
other than things that are stored in that environment.  That's probably 
not true, but it would be safe.  This mechanism is for finalizing things 
that R doesn't know about.


If you want to be less conservative, then you could look at the source 
code:  currently R_RunExitFinalizers is the very first

part of the cleanup.  I don't know if we guarantee this though.

Duncan Murdoch


Is there any further documentation on what happens when an R session
shuts down and in which order?

/Henrik



  Duncan Murdoch

  Michael

  On Fri, Mar 11, 2011 at 10:19 AM, Jeffrey
  Ryanjeffrey.r...@lemnica.comwrote:

  Take a look at reg.finalizer.  You'd have to create an object
  internally that would persist until R exits - and a related function
  to handle cleanup of course.
  
  HTH
  Jeff
  
  On Fri, Mar 11, 2011 at 12:08 PM, Michael Lawrence
  lawrence.mich...@gene.comwrote:
  Hi,
  
  Is there any way that a package can listen for when R quits? The 
Qt
stuff
  is
  hooking into platform-specific event loops and when those die
  unexpectedly
  (from the perspective of Qt), it aborts, causing an annoying 
error
  dialog.
  If we could catch when R is killed, we could cleanup, like we do
with
  .onUnload.
  
  Thanks,
  Michael
  
 [[alternative HTML version deleted]]
  
  __
  R-devel@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-devel
  
  
  
  
  --
  Jeffrey Ryan
  jeffrey.r...@lemnica.com
  
  www.lemnica.com
  

  [[alternative HTML version deleted]]

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

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


  --
  Brian D. Ripley,  rip...@stats.ox.ac.uk
  Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
  University of Oxford, Tel:  +44 1865 272861 (self)
  1 South Parks Road, +44 1865 272866 (PA)
  Oxford OX1 3TG, UKFax:  +44 1865 272595

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



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