Re: [Rd] binary form of is() contradicts its unary form

2017-11-30 Thread Suzen, Mehmet
On 30 November 2017 at 16:30, Iñaki Úcar  wrote:
> If you really believe that references should be needed to know what to
> expect from a function call, then we work with different definitions

A behaviour of a function call might be quite complex depending on
the arguments characteristics,  it may not possible always to boil
down all possible behaviours of a function to a man page as in `?`,
and sometimes giving a reference to a larger exposition makes more
sense.

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-30 Thread Iñaki Úcar
2017-11-30 15:54 GMT+01:00 Suzen, Mehmet :
>
>
> On 30 Nov 2017 14:32, "Iñaki Úcar"  wrote:
>
>>>
>>> Am I supposed to read every reference on a man page just to know what
>>> to expect from a function?
>>>
>>
>> If the reference is from John Chamber, you are supposed to read it.
>
> As a joke, it's funny.
>
>
>
> Not a joke. John Chambers is the authority in R object systems. Please do
> not mock him or resources pointing to his works.

I perfectly know John Chambers' work, thank you, and there was no
mockery towards him.

If you really believe that references should be needed to know what to
expect from a function call, then we work with different definitions
of "manual". But judging from the excellent R documentation, I would
say that the R maintainers don't share your view.

Iñaki

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-30 Thread Suzen, Mehmet
On 30 Nov 2017 14:32, "Iñaki Úcar"  wrote:

>>
>> Am I supposed to read every reference on a man page just to know what
>> to expect from a function?
>>
>
> If the reference is from John Chamber, you are supposed to read it.

As a joke, it's funny.



Not a joke. John Chambers is the authority in R object systems. Please do
not mock him or resources pointing to his works.



> It is not always possible for maintainers to document everything on a man
page.

My only point is that Hervé's concern is perfectly legitimate given
the output of "?is". Whether the inconsistency is in the behaviour of
the function or in the documentation, that I don't know. Personally, I


There is no inconsistency as far as I understood; Data.frame do not have a
pure S4 super-class hierachy.

[[alternative HTML version deleted]]

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-30 Thread Martin Maechler
> Iñaki Úcar 
> on Thu, 30 Nov 2017 14:32:12 +0100 writes:

> 2017-11-30 14:13 GMT+01:00 Suzen, Mehmet :
>> On 30 November 2017 at 14:04, Iñaki Úcar  wrote:
>>> 
>>> Am I supposed to read every reference on a man page just to know what
>>> to expect from a function?
>>> 
>> 
>> If the reference is from John Chamber, you are supposed to read it.
   (note: it is  Chamber*s* )

> As a joke, it's funny.

>> It is not always possible for maintainers to document everything on a 
man page.

Correct.  But honestly, I'm not even sure if John Chambers'
change to the help page last October dropped that description of
is() on purpose.   In my eyes, the main change to the help page was to
deemphasize the use of setIs(), and document that separately
(for experts, whereas the doc for is() and extends() is for mere useRs) :


r71460 | jmc | 2016-10-06 20:23:19 +0200 (Thu, 06. Oct 2016) |

   M src/library/methods/man/as.Rd
   M src/library/methods/man/is.Rd
   A src/library/methods/man/setAs.Rd
   A src/library/methods/man/setIs.Rd
   M src/library/methods/man/setMethod.Rd

Further changes to separate user-relevant doc. for is(), as().
Change examples in setMethod() to be acceptable R code 



> My only point is that Hervé's concern is perfectly legitimate given
> the output of "?is". 

I'd tend to agree -- but am *not* volunteering to fix it, currently.

> Whether the inconsistency is in the behaviour of
> the function or in the documentation, that I don't know. Personally, I
> think that having two functions (is, extends) with exactly the same
> output wouldn't be very practical. 

They have different "input", (or---better language-- 'argument's) :

is(, ..)
   extends(,  ..)

I would also tend to agree with Hervé that the binary and unary
uses of is()  "should be" consistent, as they are for S4, where
indeed, is() stems from.

> But it's a fact that the difference
> is not currently addressed in the man page.

correct, too.

> Iñaki

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


Re: [Rd] binary form of is() contradicts its unary form

2017-11-30 Thread Iñaki Úcar
2017-11-30 14:13 GMT+01:00 Suzen, Mehmet :
> On 30 November 2017 at 14:04, Iñaki Úcar  wrote:
>>
>> Am I supposed to read every reference on a man page just to know what
>> to expect from a function?
>>
>
> If the reference is from John Chamber, you are supposed to read it.

As a joke, it's funny.

> It is not always possible for maintainers to document everything on a man 
> page.

My only point is that Hervé's concern is perfectly legitimate given
the output of "?is". Whether the inconsistency is in the behaviour of
the function or in the documentation, that I don't know. Personally, I
think that having two functions (is, extends) with exactly the same
output wouldn't be very practical. But it's a fact that the difference
is not currently addressed in the man page.

Iñaki

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-30 Thread Suzen, Mehmet
On 30 November 2017 at 14:04, Iñaki Úcar  wrote:
>
> Am I supposed to read every reference on a man page just to know what
> to expect from a function?
>

If the reference is from John Chamber, you are supposed to read it.
It is not always possible for maintainers to document everything on a man page.

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-30 Thread Iñaki Úcar
2017-11-30 13:26 GMT+01:00 Suzen, Mehmet :
> On 30 November 2017 at 11:37, Iñaki Úcar  wrote:
>> 2017-11-30 3:14 GMT+01:00 Suzen, Mehmet :
>>> My understanding is that there is no inconsistency. `is` does what it
>>> claims, from the documentation:
>>>
>>> ‘is’: With two arguments, tests whether ‘object’ can be treated as
>>>   from ‘class2’.
>>>
>>>   With one argument, returns all the super-classes of this
>>>   object's class.
>>
>> Note that this is not in the documentation since a year ago.
>>
>
> As far as I understood and gather, starting from methods v3.3.2, the following
> new reference is added:
>
> * Chambers, John M. (2016) Extending R, Chapman & Hall. (Chapters 9 and 10.)
>
> Pushing that details there, I assume.

Am I supposed to read every reference on a man page just to know what
to expect from a function?

Iñaki

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-30 Thread Suzen, Mehmet
On 30 November 2017 at 11:37, Iñaki Úcar  wrote:
> 2017-11-30 3:14 GMT+01:00 Suzen, Mehmet :
>> My understanding is that there is no inconsistency. `is` does what it
>> claims, from the documentation:
>>
>> ‘is’: With two arguments, tests whether ‘object’ can be treated as
>>   from ‘class2’.
>>
>>   With one argument, returns all the super-classes of this
>>   object's class.
>
> Note that this is not in the documentation since a year ago.
>

As far as I understood and gather, starting from methods v3.3.2, the following
new reference is added:

* Chambers, John M. (2016) Extending R, Chapman & Hall. (Chapters 9 and 10.)

Pushing that details there, I assume.

Best,
Mehmet

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-30 Thread Iñaki Úcar
2017-11-30 3:14 GMT+01:00 Suzen, Mehmet :
> My understanding is that there is no inconsistency. `is` does what it
> claims, from the documentation:
>
> ‘is’: With two arguments, tests whether ‘object’ can be treated as
>   from ‘class2’.
>
>   With one argument, returns all the super-classes of this
>   object's class.

Note that this is not in the documentation since a year ago.

Iñaki

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-29 Thread Suzen, Mehmet
On 29 November 2017 at 21:45, Hervé Pagès  wrote:
> You're missing the point of my original post. Which is that
> there is a serious inconsistency between the unary and binary
> forms of is(). Maybe the binary form is right in case of

My understanding is that there is no inconsistency. `is` does what it
claims, from the documentation:

‘is’: With two arguments, tests whether ‘object’ can be treated as
  from ‘class2’.

  With one argument, returns all the super-classes of this
  object's class.

Important verb there is 'can be treated as from' with two arguments. So,
one can not treat `data.frame` as from 'list' class in a simple sense,
even though it inherits
from list. The complication is that list is a Primitive and this is
not coming from a
clean S4 hierarchy c.f, your A, B example.

Also, strictly speaking, having super-classes resolved does not
automatically qualify an
assumption that the object can be treated as a class of one of its
super-classes.

Cheers,
Mehmet

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-29 Thread Hervé Pagès

Yes, data.frame is not an S4 class but is(data.frame())
finds its super-classes anyway and without the need to wrap
it in asS4(). And "list' is one of the super-classes. Then
is(data.frame(), "list") contradicts this.

I'm not asking for a workaround. I already have one with
'class2 %in% is(object)' as reported in my original post.
'is(asS4(object), class2)' is maybe another one but, unlike
the former, it's not obvious that it will behave consistently
with unary is(). There could be some other surprise on the
way.

You're missing the point of my original post. Which is that
there is a serious inconsistency between the unary and binary
forms of is(). Maybe the binary form is right in case of
is(data.frame(), "list"). But then the unary form should not
return "list'. This inconsistency will potentially hurt anybody
who tries to do computations on a class hierarchy, especially
if the hierarchy is complex and mixes S4 and S3 classes. So I'm
hoping this can be addressed. Hope you understand.

Cheers,
H.


On 11/29/2017 12:21 PM, Suzen, Mehmet wrote:

Hi Herve,

Interesting observation with `setClass` but it is for S4.  It looks
like `data.frame()` is not an S4 class.


isS4(data.frame())

[1] FALSE

And in your case this might help:


is(asS4(data.frame()), "list")

[1] TRUE

Looks like `is` is designed for S4 classes, I am not entirely sure.

Best,
-Mehmet

On 29 November 2017 at 20:46, Hervé Pagès  wrote:

Hi Mehmet,

On 11/29/2017 11:22 AM, Suzen, Mehmet wrote:


Hi Herve,

I think you are confusing subclasses and classes. There is no
contradiction. `is` documentation
is very clear:

`With one argument, returns all the super-classes of this object's class.`



Yes that's indeed very clear. So if "list" is a super-class
of "data.frame" (as reported by is(data.frame())), then
is(data.frame(), "list") should be TRUE.

With S4 classes:

   setClass("A")
   setClass("B", contains="A")

   ## Get all the super-classes of B.
   is(new("B"))
   # [1] "B" "A"

   ## Does a B object inherit from A?
   is(new("B"), "A")
   # [1] TRUE

Cheers,
H.



Note that object class is always `data.frame` here, check:

  > class(data.frame())
[1] "data.frame"
  > is(data.frame(), "data.frame")
[1] TRUE

Best,
Mehmet





On 29 Nov 2017 19:13, "Hervé Pagès" mailto:hpa...@fredhutch.org>> wrote:

 Hi,

 The unary forms of is() and extends() report that data.frame
 extends list, oldClass, and vector:

> is(data.frame())
[1] "data.frame" "list"   "oldClass"   "vector"

> extends("data.frame")
[1] "data.frame" "list"   "oldClass"   "vector"

 However, the binary form of is() disagrees:

> is(data.frame(), "list")
[1] FALSE
> is(data.frame(), "oldClass")
[1] FALSE
> is(data.frame(), "vector")
[1] FALSE

 while the binary form of extends() agrees:

> extends("data.frame", "list")
[1] TRUE
> extends("data.frame", "oldClass")
[1] TRUE
> extends("data.frame", "vector")
[1] TRUE

 Who is right?

 Shouldn't 'is(object, class2)' be equivalent
 to 'class2 %in% is(object)'? Furthermore, is there
 any reason why 'is(object, class2)' is not implemented
 as 'class2 %in% is(object)'?

 Thanks,
 H.

 --
 Hervé Pagès

 Program in Computational Biology
 Division of Public Health Sciences
 Fred Hutchinson Canc

er
 Research Center
 1100 Fairview Ave. N, M1-B514
 P.O. Box 19024
 Seattle, WA 98109-1024

 E-mail: hpa...@fredhutch.org 
 Phone:  (206) 667-5791
 Fax:(206) 667-1319

 __
 R-devel@r-project.org  mailing list
 
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwIFaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=Edo4xQQyNSdlhiJjtVDnOcunTA8a6KT5EN7_jowitP8&s=ES11eQ8qMdiYMc5X-SbEfQyy2VoX6MUfX0skN-QWunc&e=





--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:(206) 667-1319


--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchins

Re: [Rd] binary form of is() contradicts its unary form

2017-11-29 Thread Suzen, Mehmet
Hi Herve,

Interesting observation with `setClass` but it is for S4.  It looks
like `data.frame()` is not an S4 class.

> isS4(data.frame())
[1] FALSE

And in your case this might help:

> is(asS4(data.frame()), "list")
[1] TRUE

Looks like `is` is designed for S4 classes, I am not entirely sure.

Best,
-Mehmet

On 29 November 2017 at 20:46, Hervé Pagès  wrote:
> Hi Mehmet,
>
> On 11/29/2017 11:22 AM, Suzen, Mehmet wrote:
>>
>> Hi Herve,
>>
>> I think you are confusing subclasses and classes. There is no
>> contradiction. `is` documentation
>> is very clear:
>>
>> `With one argument, returns all the super-classes of this object's class.`
>
>
> Yes that's indeed very clear. So if "list" is a super-class
> of "data.frame" (as reported by is(data.frame())), then
> is(data.frame(), "list") should be TRUE.
>
> With S4 classes:
>
>   setClass("A")
>   setClass("B", contains="A")
>
>   ## Get all the super-classes of B.
>   is(new("B"))
>   # [1] "B" "A"
>
>   ## Does a B object inherit from A?
>   is(new("B"), "A")
>   # [1] TRUE
>
> Cheers,
> H.
>
>>
>> Note that object class is always `data.frame` here, check:
>>
>>  > class(data.frame())
>> [1] "data.frame"
>>  > is(data.frame(), "data.frame")
>> [1] TRUE
>>
>> Best,
>> Mehmet
>>
>>
>>
>>
>>
>> On 29 Nov 2017 19:13, "Hervé Pagès" > > wrote:
>>
>> Hi,
>>
>> The unary forms of is() and extends() report that data.frame
>> extends list, oldClass, and vector:
>>
>>> is(data.frame())
>>[1] "data.frame" "list"   "oldClass"   "vector"
>>
>>> extends("data.frame")
>>[1] "data.frame" "list"   "oldClass"   "vector"
>>
>> However, the binary form of is() disagrees:
>>
>>> is(data.frame(), "list")
>>[1] FALSE
>>> is(data.frame(), "oldClass")
>>[1] FALSE
>>> is(data.frame(), "vector")
>>[1] FALSE
>>
>> while the binary form of extends() agrees:
>>
>>> extends("data.frame", "list")
>>[1] TRUE
>>> extends("data.frame", "oldClass")
>>[1] TRUE
>>> extends("data.frame", "vector")
>>[1] TRUE
>>
>> Who is right?
>>
>> Shouldn't 'is(object, class2)' be equivalent
>> to 'class2 %in% is(object)'? Furthermore, is there
>> any reason why 'is(object, class2)' is not implemented
>> as 'class2 %in% is(object)'?
>>
>> Thanks,
>> H.
>>
>> --
>> Hervé Pagès
>>
>> Program in Computational Biology
>> Division of Public Health Sciences
>> Fred Hutchinson Canc
>>
>> er
>> Research Center
>> 1100 Fairview Ave. N, M1-B514
>> P.O. Box 19024
>> Seattle, WA 98109-1024
>>
>> E-mail: hpa...@fredhutch.org 
>> Phone:  (206) 667-5791
>> Fax:(206) 667-1319
>>
>> __
>> R-devel@r-project.org  mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>> 
>>
>
> --
> Hervé Pagès
>
> Program in Computational Biology
> Division of Public Health Sciences
> Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N, M1-B514
> P.O. Box 19024
> Seattle, WA 98109-1024
>
> E-mail: hpa...@fredhutch.org
> Phone:  (206) 667-5791
> Fax:(206) 667-1319

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-29 Thread Hervé Pagès

Hi Mehmet,

On 11/29/2017 11:22 AM, Suzen, Mehmet wrote:

Hi Herve,

I think you are confusing subclasses and classes. There is no
contradiction. `is` documentation
is very clear:

`With one argument, returns all the super-classes of this object's class.`


Yes that's indeed very clear. So if "list" is a super-class
of "data.frame" (as reported by is(data.frame())), then
is(data.frame(), "list") should be TRUE.

With S4 classes:

  setClass("A")
  setClass("B", contains="A")

  ## Get all the super-classes of B.
  is(new("B"))
  # [1] "B" "A"

  ## Does a B object inherit from A?
  is(new("B"), "A")
  # [1] TRUE

Cheers,
H.



Note that object class is always `data.frame` here, check:

 > class(data.frame())
[1] "data.frame"
 > is(data.frame(), "data.frame")
[1] TRUE

Best,
Mehmet





On 29 Nov 2017 19:13, "Hervé Pagès" mailto:hpa...@fredhutch.org>> wrote:

Hi,

The unary forms of is() and extends() report that data.frame
extends list, oldClass, and vector:

   > is(data.frame())
   [1] "data.frame" "list"   "oldClass"   "vector"

   > extends("data.frame")
   [1] "data.frame" "list"   "oldClass"   "vector"

However, the binary form of is() disagrees:

   > is(data.frame(), "list")
   [1] FALSE
   > is(data.frame(), "oldClass")
   [1] FALSE
   > is(data.frame(), "vector")
   [1] FALSE

while the binary form of extends() agrees:

   > extends("data.frame", "list")
   [1] TRUE
   > extends("data.frame", "oldClass")
   [1] TRUE
   > extends("data.frame", "vector")
   [1] TRUE

Who is right?

Shouldn't 'is(object, class2)' be equivalent
to 'class2 %in% is(object)'? Furthermore, is there
any reason why 'is(object, class2)' is not implemented
as 'class2 %in% is(object)'?

Thanks,
H.

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Canc

er
Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org 
Phone:  (206) 667-5791
Fax:(206) 667-1319

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





--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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

Re: [Rd] binary form of is() contradicts its unary form

2017-11-29 Thread Suzen, Mehmet
Hi Herve,

I think you are confusing subclasses and classes. There is no
contradiction. `is` documentation
is very clear:

`With one argument, returns all the super-classes of this object's class.`

Note that object class is always `data.frame` here, check:

> class(data.frame())
[1] "data.frame"
> is(data.frame(), "data.frame")
[1] TRUE

Best,
Mehmet





On 29 Nov 2017 19:13, "Hervé Pagès"  wrote:

> Hi,
>
> The unary forms of is() and extends() report that data.frame
> extends list, oldClass, and vector:
>
>   > is(data.frame())
>   [1] "data.frame" "list"   "oldClass"   "vector"
>
>   > extends("data.frame")
>   [1] "data.frame" "list"   "oldClass"   "vector"
>
> However, the binary form of is() disagrees:
>
>   > is(data.frame(), "list")
>   [1] FALSE
>   > is(data.frame(), "oldClass")
>   [1] FALSE
>   > is(data.frame(), "vector")
>   [1] FALSE
>
> while the binary form of extends() agrees:
>
>   > extends("data.frame", "list")
>   [1] TRUE
>   > extends("data.frame", "oldClass")
>   [1] TRUE
>   > extends("data.frame", "vector")
>   [1] TRUE
>
> Who is right?
>
> Shouldn't 'is(object, class2)' be equivalent
> to 'class2 %in% is(object)'? Furthermore, is there
> any reason why 'is(object, class2)' is not implemented
> as 'class2 %in% is(object)'?
>
> Thanks,
> H.
>
> --
> Hervé Pagès
>
> Program in Computational Biology
> Division of Public Health Sciences
> Fred Hutchinson Canc
> er
> Research Center
> 1100 Fairview Ave. N, M1-B514
> P.O. Box 19024
> Seattle, WA 98109-1024
>
> E-mail: hpa...@fredhutch.org
> Phone:  (206) 667-5791
> Fax:(206) 667-1319
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

[[alternative HTML version deleted]]

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

[Rd] binary form of is() contradicts its unary form

2017-11-29 Thread Hervé Pagès

Hi,

The unary forms of is() and extends() report that data.frame
extends list, oldClass, and vector:

  > is(data.frame())
  [1] "data.frame" "list"   "oldClass"   "vector"

  > extends("data.frame")
  [1] "data.frame" "list"   "oldClass"   "vector"

However, the binary form of is() disagrees:

  > is(data.frame(), "list")
  [1] FALSE
  > is(data.frame(), "oldClass")
  [1] FALSE
  > is(data.frame(), "vector")
  [1] FALSE

while the binary form of extends() agrees:

  > extends("data.frame", "list")
  [1] TRUE
  > extends("data.frame", "oldClass")
  [1] TRUE
  > extends("data.frame", "vector")
  [1] TRUE

Who is right?

Shouldn't 'is(object, class2)' be equivalent
to 'class2 %in% is(object)'? Furthermore, is there
any reason why 'is(object, class2)' is not implemented
as 'class2 %in% is(object)'?

Thanks,
H.

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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