Re: [R] peculiar matrices

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sat 22 Oct 2005 - 12:24:37 EST

The reference manual of 2.2.0 says in section 2.2 that "Matrices and arrays are simply vectors with the attribute dim and optionally dimnames."

Now earlier in section 2.1 it discusses vectors and I think that that is where the confusing part lies. Section 2.1 starts out saying that "Vectors can be thought of as contiguous cells containing homogeneous data." and that "R has six basic ('atomic') vector types: logical, integer, real, complex, string (or character) and raw". There is no inkling yet that this is an incomplete thought.

Its only later in the section that we find out that atomic vectors are only one sort of vector: "Lists are vectors, and the basic vector types are referred to as atomic vectors where it is necessary to exclude lists."

I think this section should be rewritten to clearly state up front that there are atomic vectors and generic vectors and then define each of these.

On 10/21/05, Ben Bolker <bolker@ufl.edu> wrote:
>
> As far as I can tell from reading The Fine Documentation
> (R Language Definition and Intro to R), matrices are supposed
> to be of homogeneous types. Yet giving matrix() an inhomogeneous
> list seems to work, although it produces a peculiar object:
>
> v = list(1:3,4,5,"a")
> m = matrix(v,nrow=2)
> m
>
> [,1] [,2]
> [1,] Integer,3 5
> [2,] 4 "a"
>
>
> m[1,]
>
> [[1]]
> [1] 1 2 3
>
> [[2]]
> [1] 3
>
> (this is R 2.1.1, running under Linux)
> Should there be a check/error? Or is this just analogous to
> the joke about going to the doctor and saying "it hurts when
> I do this", and the doctor saying "well then, don't do that"?
>
> Ben Bolker
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Oct 22 12:30:36 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 19:17:37 EST