# Making 2 dimensional vector from the 3 dimensional one

4 messages
Open this post in threaded view
|
Report Content as Inappropriate

## Making 2 dimensional vector from the 3 dimensional one

 Hi All, I want to make a 1 dimension vector from the first two dimensions of a 3 dimension array, so make a 2 dimension vector from a 3-dimension one, with "fusing" (making as.vector) the first two dimensions. It seems to be very easy, but I cannot find the solution, I mean it would very strange, that I would do taking the single 1 dimensional vectors from the 3 dimensional one, make one vector from the first two vectors and make two dimension from the original 3rd one and this new one, but  I think there would be an easier way that I do not find. Could you help me, please? Thanks very much, Gabi         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Making 2 dimensional vector from the 3 dimensional one

 On 14/07/17 21:43, Csima, Gabriella wrote: > Hi All, > I want to make a 1 dimension vector from the first two dimensions of a 3 dimension array, so make a 2 dimension vector from a 3-dimension one, with "fusing" (making as.vector) the first two dimensions. > It seems to be very easy, but I cannot find the solution, I mean it would very strange, that I would do taking the single 1 dimensional vectors from the 3 dimensional one, make one vector from the first two vectors and make two dimension from the original 3rd one and this new one, but  I think there would be an easier way that I do not find. > Could you help me, please? > Thanks very much, (1) Please avoid posting in HTML (although no great harm was done in this instance).  This is a plain text mailing list, and HTML often makes a mess. (2) Spend some time learning R (e.g. read "An Introduction to R" from the R web site).  In particular learn about array indexing. (3) It is not *at all* clear to me what you actually want to do.  A simple example of what you've got and what you want to get would help. (4) What on earth do you mean by "a 1 dimension vector"?  A 1 dimensional vector is a scalar.  I can't believe that this is actually what you are talking about.  Please clarify. cheers, Rolf Turner -- Technical Editor ANZJS Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Making 2 dimensional vector from the 3 dimensional one

 In reply to this post by Csima, Gabriella Hi Gabi, Let's say you have something like this: gc_array<-array(1:27,c(3,3,3)) > gc_array , , 1     [,1] [,2] [,3] [1,]    1    4    7 [2,]    2    5    8 [3,]    3    6    9 , , 2     [,1] [,2] [,3] [1,]   10   13   16 [2,]   11   14   17 [3,]   12   15   18 , , 3     [,1] [,2] [,3] [1,]   19   22   25 [2,]   20   23   26 [3,]   21   24   27 You seem to want to collapse this into a two dimensional array using the values in the three dimensional array. For instance, if you want to collapse in the third dimension by summing the values in each 2D "slice": > gc_array[,,1]+gc_array[,,2]+gc_array[,,3]     [,1] [,2] [,3] [1,]   30   39   48 [2,]   33   42   51 [3,]   36   45   54 The problem is working out whether the result means what you want. If the first two dimensions were geographic coordinates and the third contained a series of measurements over time, then you would have the aggregate of those measures over time. Is this what you are trying to do? Jim On Fri, Jul 14, 2017 at 7:43 PM, Csima, Gabriella <[hidden email]> wrote: > Hi All, > I want to make a 1 dimension vector from the first two dimensions of a 3 dimension array, so make a 2 dimension vector from a 3-dimension one, with "fusing" (making as.vector) the first two dimensions. > It seems to be very easy, but I cannot find the solution, I mean it would very strange, that I would do taking the single 1 dimensional vectors from the 3 dimensional one, make one vector from the first two vectors and make two dimension from the original 3rd one and this new one, but  I think there would be an easier way that I do not find. > Could you help me, please? > Thanks very much, > Gabi > > >         [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > 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. ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.