From becker@g@be @ending from gene@com  Sat Jul  7 20:50:57 2018
From: becker@g@be @ending from gene@com (Gabe Becker)
Date: Sat, 7 Jul 2018 11:50:57 -0700
Subject: [Rd] Testing for vectors
In-Reply-To: <CABdHhvHuqb82RjNwD4US_oD1pEXLdc2C3YRYpCaV7QTYhUVB9g@mail.gmail.com>
References: <CABdHhvF5gqJt3kDj-QuU92BWPiLWwGugxnNzOfHOHo9tp_AigA@mail.gmail.com>
 <2b0f1462-99d1-d908-5ea6-e9d21be02d11@gmail.com>
 <CABdHhvHuqb82RjNwD4US_oD1pEXLdc2C3YRYpCaV7QTYhUVB9g@mail.gmail.com>
Message-ID: <CAMFmJs=Fybj+FA1anmPSsWBnak+msX5C2524G=sZ9jFOnJtCTw@mail.gmail.com>

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?

You can have a 1d array which is different from what your proposed function
would call a vector. So is.null(dim(x)) doesn't seem the same as 1d, right?

> x = array(1:10)

> x

 [1]  1  2  3  4  5  6  7  8  9 10

> class(x)

[1] "array"

> dim(x)

[1] 10

> dim(1:10)

NULL


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.

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.

Best,
~G



>
> (I don't have any feel for whether the check should be is.null(dim(x))
> vs. length(dim(x)) <= 1)
>
> Hadley
> --
> http://hadley.nz
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>


-- 
Gabriel Becker, Ph.D
Scientist
Bioinformatics and Computational Biology
Genentech Research

	[[alternative HTML version deleted]]



[Rd] Testing for vectors
Gabe Becker