Skip to content

grid unit bug? (PR#14220)

3 messages · Brian Ripley, Bert Gunter

#
Paul:

I figured that would be the problem.

I encountered the issue when I tries to check arguments in a validDetails
method for a grob.

Could one substitute the following function in the grid namespace?

is.numeric <- function(x)if(is.unit(x))TRUE else is.numeric(x)

(or make the first clause FALSE)

Obviously, messing around like this might be dangerous -- or at least would
compromise execution speed.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
 
 

-----Original Message-----
From: paul murrell [mailto:R-bugs at r-project.org] 
Sent: Wednesday, February 24, 2010 4:22 PM
To: gunter.berton at gene.com
Subject: Re: grid unit bug? (PR#14220)
These results simply reflect the underlying data structures (simple "unit"s
are
just numeric vectors, but more complex "unit.arithmetic"s are lists).  I
don't
see how I can "hide" the numeric-ness of simple units (just like there's no
way
to stop a "ts" object like 'Nile' from satisfying is.numeric()).  I could
re-implement simple units as lists, but (apart from the work involved) that
would be (even) less efficient.

1. Is there a situation where this causes a problem?

2. Do you have a possible "fix" in mind?

Paul
#
is.numeric() is generic.  So grid could include

is.numeric.unit <- function(x) FALSE

and register it in its namespace.   Or Bert could define it in his 
application.
On Thu, 25 Feb 2010, gunter.berton at gene.com wrote:

            

  
    
#
Thank you Brian:

Maybe I should follow my own advice! I DID check methods(is.numeric) to see
if that were the case, but concluded it was not as that yielded an error.
But all I needed to do was read the docs! Registering the method indeed
seems the right way to do it.

Best regards,

Bert Gunter
Genentech Nonclinical Biostatistics
 
 -----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] 
Sent: Wednesday, February 24, 2010 11:13 PM
To: gunter.berton at gene.com; paul at stat.auckland.ac.nz
Cc: r-devel at stat.math.ethz.ch; R-bugs at r-project.org
Subject: Re: [Rd] grid unit bug? (PR#14220)

is.numeric() is generic.  So grid could include

is.numeric.unit <- function(x) FALSE

and register it in its namespace.   Or Bert could define it in his 
application.
On Thu, 25 Feb 2010, gunter.berton at gene.com wrote:

            
would
"unit"s
no
that