[R] Dimension of a vector

From: <maj_at_stats.waikato.ac.nz>
Date: Wed, 5 Dec 2007 13:35:32 +1300 (NZDT)


Consider the following:
> A <- 1:10
> A

 [1] 1 2 3 4 5 6 7 8 9 10
> dim(A)

NULL
> dim(A) <- c(2,5)
> A

     [,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
> dim(A)

[1] 2 5
> dim(A) <- 10
> A

 [1] 1 2 3 4 5 6 7 8 9 10
> dim(A)

[1] 10

Would it not make sense to have dim(A) = length(A) for all vectors?

Murray

-- 
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj_at_waikato.ac.nz                                Fax 7 838 4155
Phone  +64 7 838 4773 wk    Home +64 7 825 0441    Mobile 021 1395 862

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 05 Dec 2007 - 00:39:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 05 Dec 2007 - 07:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.