On Fri, Feb 2, 2018 at 12:07 AM, Martin Maechler
wrote:
>> Henrik Bengtsson
>> on Thu, 1 Feb 2018 10:26:23 -0800 writes:
>
> > On Thu, Feb 1, 2018 at 12:14 AM, Martin Maechler
> > wrote:
> >>> Michael Lawrence
> >>> on Tue, 30 Jan 2018 15:57:42 -0800 writes:
Maybe behavior of 'as.list' in R is not inherited from S?
- From https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=78 , in "the
prototype" (S), 'as.list' on a data frame gave a list, not a data frame as
given by the default 'as.list' in R. That led to introduction of
'as.list.data.frame'.
- F
> Henrik Bengtsson
> on Thu, 1 Feb 2018 10:26:23 -0800 writes:
> On Thu, Feb 1, 2018 at 12:14 AM, Martin Maechler
> wrote:
>>> Michael Lawrence
>>> on Tue, 30 Jan 2018 15:57:42 -0800 writes:
>>
>> > I just meant that the minimal contract for as.list(
On Thu, Feb 1, 2018 at 12:14 AM, Martin Maechler
wrote:
>> Michael Lawrence
>> on Tue, 30 Jan 2018 15:57:42 -0800 writes:
>
> > I just meant that the minimal contract for as.list() appears to be that
> it
> > returns a VECSXP. To the user, we might say that is.list() will alw
> Michael Lawrence
> on Thu, 1 Feb 2018 06:12:20 -0800 writes:
> On Thu, Feb 1, 2018 at 1:21 AM, Martin Maechler
> wrote:
>> > Michael Lawrence
>> > on Tue, 30 Jan 2018 10:37:38 -0800 writes:
>>
>> > I agree that it would make sense for the obj
On Thu, Feb 1, 2018 at 1:21 AM, Martin Maechler
wrote:
> > Michael Lawrence
> > on Tue, 30 Jan 2018 10:37:38 -0800 writes:
>
> > I agree that it would make sense for the object to have c("by",
> "list") as
> > its class attribute, since the object is known to behave as a list
> Michael Lawrence
> on Tue, 30 Jan 2018 10:37:38 -0800 writes:
> I agree that it would make sense for the object to have c("by", "list") as
> its class attribute, since the object is known to behave as a list.
Well, but that (list behavior) applies to most non-simple S3
clas
> Michael Lawrence
> on Tue, 30 Jan 2018 15:57:42 -0800 writes:
> I just meant that the minimal contract for as.list() appears to be that it
> returns a VECSXP. To the user, we might say that is.list() will always
> return TRUE.
Indeed. I also agree with Herv'e that t
I just meant that the minimal contract for as.list() appears to be that it
returns a VECSXP. To the user, we might say that is.list() will always
return TRUE. I'm not sure we can expect consistency across methods beyond
that, nor is it feasible at this point to match the semantics of the
methods pa
On 01/30/2018 02:50 PM, Michael Lawrence wrote:
by() does not always return a list. In Gabe's example, it returns an
integer, thus it is coerced to a list. as.list() means that it should be
a VECSXP, not necessarily with "list" in the class attribute.
The documentation is not particularly clea
by() does not always return a list. In Gabe's example, it returns an
integer, thus it is coerced to a list. as.list() means that it should be a
VECSXP, not necessarily with "list" in the class attribute.
Michael
On Tue, Jan 30, 2018 at 2:41 PM, Hervé Pagès wrote:
> Hi Gabe,
>
> Interestingly th
Hi Gabe,
Interestingly the behavior of as.list() on by objects seem to
depend on the object itself:
> b1 <- by(1:2, 1:2, identity)
> class(as.list(b1))
[1] "list"
> b2 <- by(warpbreaks[, 1:2], warpbreaks[,"tension"], summary)
> class(as.list(b2))
[1] "by"
This is with R 3.4.3 and R devel (2017
Dario,
What version of R are you using. In my mildly old 3.4.0 installation and in
the version of Revel I have lying around (also mildly old...) I don't see
the behavior I think you are describing
> b = by(1:2, 1:2, identity)
> class(as.list(b))
[1] "list"
> sessionInfo()
R Under development
On 01/30/2018 02:24 PM, Hervé Pagès wrote:
I agree that it makes sense to expect as.list() to perform
a "strict coercion" i.e. to return an object of class "list",
*even* on a list derivative. That's what as( , "list") does
by default:
# on a data.frame object
as(data.frame(), "list") # o
I agree that it makes sense to expect as.list() to perform
a "strict coercion" i.e. to return an object of class "list",
*even* on a list derivative. That's what as( , "list") does
by default:
# on a data.frame object
as(data.frame(), "list") # object of class "list"
I agree that it would make sense for the object to have c("by", "list") as
its class attribute, since the object is known to behave as a list.
However, it would may be too disruptive to make this change at this point.
Hard to predict.
Michael
On Mon, Jan 29, 2018 at 5:00 PM, Dario Strbenac
wrote
Good day,
I'd like to suggest the addition of an as.list method for a by object that
actually returns a list of class "list". This would make it safer to do
type-checking, because is.list also returns TRUE for a data.frame variable and
using class(result) == "list" is an alternative that only r
17 matches
Mail list logo