From h@wickh@m @ending from gm@il@com  Mon Jul  9 01:13:41 2018
From: h@wickh@m @ending from gm@il@com (Hadley Wickham)
Date: Sun, 8 Jul 2018 18:13:41 -0500
Subject: [Rd] Testing for vectors
In-Reply-To: <CAMFmJsmYxCmHx1zNQ3mgwEWA_-98rAusE3bunTKwavHYaiHDAA@mail.gmail.com>
References: <CABdHhvF5gqJt3kDj-QuU92BWPiLWwGugxnNzOfHOHo9tp_AigA@mail.gmail.com>
 <2b0f1462-99d1-d908-5ea6-e9d21be02d11@gmail.com>
 <CABdHhvHuqb82RjNwD4US_oD1pEXLdc2C3YRYpCaV7QTYhUVB9g@mail.gmail.com>
 <CAMFmJs=Fybj+FA1anmPSsWBnak+msX5C2524G=sZ9jFOnJtCTw@mail.gmail.com>
 <CABdHhvHkRcx=S5ShWkK4Y-yipX-F=xOx=8R1qm8qxeEDojrrCw@mail.gmail.com>
 <CAMFmJsmYxCmHx1zNQ3mgwEWA_-98rAusE3bunTKwavHYaiHDAA@mail.gmail.com>
Message-ID: <CABdHhvHj3ZUQhqzBQP+1gb=fO9g2w4buKnbGGrmJHof3WZtZjg@mail.gmail.com>

On Sat, Jul 7, 2018 at 11:19 PM, Gabe Becker <becker.gabe at gene.com> wrote:
> Hadley,
>
>
> On Sat, Jul 7, 2018 at 1:32 PM, Hadley Wickham <h.wickham at gmail.com> wrote:
>>
>> On Sat, Jul 7, 2018 at 1:50 PM, Gabe Becker <becker.gabe at gene.com> wrote:
>> > Hadley,
>> >
>> >>
>> >> I was thinking primarily of completing the set of is.matrix() and
>> >> is.array(), or generally, how do you say: is `x` a 1d dimensional
>> >> thing?
>> >
>> >
>> > Can you clarify what you mean by dimensionality sense and specifically
>> > 1d
>> > here?
>>
>> What do we call a vector that is not an array? (or matrix)
>>
>> What do we call an object that acts 1-dimensional? (i.e. has
>> length(dim()) %in% c(0, 1)) ?
>
>
>
> Right, or even (length(dim()) == 0 || sum(dim() > 1) <= 1)
>
>  but that is exactly my point, those two(/three) sets of things are not the
> same. 1d arrays meet the second definition but not the first. Matrices and
> arrays that don't meet either of yours would still meet mine. Which
> definition are you proposing strictly define what a vector is?

I am not proposing any definition. I am enquiring if there is a
definition in base R. The answer appears to be now.

> Another completely unrelated way to define vector, btw, is via the vector
> interface (from what I recall this is roughly [, [[, length, and format
> methods, though I'm probably forgetting some). This is (more or less)
> equivalent to defining a vector as "a thing that can be the column of a
> data.frame and have all the base-provided machinery work".

I don't know if that definition is adequate because a call would be a
vector by that definition. I'm pretty sure a call does not make sense
as a data frame column.

Also technically data frames don't require their columns to have equal
length(), but equal NROW(). So the spirit of that definition would
imply that a matrices and arrays are also vectors, which seems like it
might be undesirable.

Hadley

-- 
http://hadley.nz



[Rd] Testing for vectors
Hadley Wickham