From otoomet @ending from gm@il@com  Sat Jul  7 22:48:55 2018
From: otoomet @ending from gm@il@com (Ott Toomet)
Date: Sat, 7 Jul 2018 13:48:55 -0700
Subject: [Rd] Testing for vectors
In-Reply-To: <CABdHhvHkRcx=S5ShWkK4Y-yipX-F=xOx=8R1qm8qxeEDojrrCw@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>
Message-ID: <CAMMJQ0b8crhiRzn5x-19RJkavwZP11kvCvFMefGfpXg0nBagOg@mail.gmail.com>

Thanks, Hadley for bringing this up:-)

I am teaching R and I can suggest 5 different definitions of 'vector':

a) vector as a collection of homogeneous objects, indexed by [ ] (more
precisely atomic vector).  Sometimes you hear that in R, "everything is a
vector", but this is only true for atomic objects.
b) vector as a collection of objects, indexed by either [ ] and [[ ]].
This includes atomic vectors and lists.
c) vector versus scalar.  It pops up when teaching math and stats, and is
somewhat confusing, in particular if my previous claim was that "R does not
have scalars".
d) vector versus matrix (or other arrays).  Again, it only matters when
doing matrix operations where 'vectors', i.e. objects with NULL dimension,
behave their own way.
e) finally, 'is.vector' has it's own understanding what constitutes a
vector.

Maybe there are more...  I don't think there are any easy answers but both
me and my students would appreciate more consistent terminology.

Cheers,
Ott



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)) ?
>
> > You can also have an n x 1 matrix, which technically has 2 dimensions but
> > conceptually is equivalent to a 1d array and/or a vector.
>
> Yes. You can also have array that's n x 1 x 1.
>
> > Also, are you including lists in your conceptions of 1d vector here? I'm
> > with Duncan here, in that i'm having trouble understanding exactly what
> you
> > want to do without a bit more context.
>
> Isn't it standard terminology that a vector is the set of atomic vectors +
> list?
>
> Hadley
>
> --
> http://hadley.nz
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



[Rd] Testing for vectors
Ott Toomet