From h@wickh@m @ending from gm@il@com  Mon Jul  9 01:10:14 2018
From: h@wickh@m @ending from gm@il@com (Hadley Wickham)
Date: Sun, 8 Jul 2018 18:10:14 -0500
Subject: [Rd] Testing for vectors
In-Reply-To: <CAMMJQ0b8crhiRzn5x-19RJkavwZP11kvCvFMefGfpXg0nBagOg@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>
 <CAMMJQ0b8crhiRzn5x-19RJkavwZP11kvCvFMefGfpXg0nBagOg@mail.gmail.com>
Message-ID: <CABdHhvE386HD0C4+YFUyQ_n1s0bvyeL+QK8XHMPxN2ccSCLOsg@mail.gmail.com>

On Sat, Jul 7, 2018 at 3:48 PM, Ott Toomet <otoomet at gmail.com> wrote:
> 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.

Yes!

And to add to the confusion there are three meanings to numeric vector:

* As an alias for double (i.e. numeric() and as.numeric())
* To refer to integer and double types jointly (as is S3 and S4 class)
* A vector that behaves as if it is a number (e.g. is.numeric(), which
excludes factors)

Hadley

-- 
http://hadley.nz



[Rd] Testing for vectors
Hadley Wickham