Skip to content

Creating a mean line plot

1 message · r@i@1290 m@iii@g oii @im@com

#
Hi Bill,

For the x-axis variable, in this case, indeed, I used rowMeans(cbind(get2.teratons, get5.teratons)). This averaged each value between these two 1-dimensional variables (i.e. value#1 of "get2.teratons" was averaged with value#1 of "get5.teratons" - this was done for all 90 values).?
To obtain the means for the values of the y-axis variables, which are 3-dimensional, I simply took each variable and divided by 2, in this case. Thus: (variableA+variableB)/2. This took the mean of the variable for each grid cell for each layer (90 layers). So, for grid cell #1, doing this averaged all 90 values corresponding to the 90 layers between the two variables. For example, the values of layer 1 of variableA and layer 1 of variableB were averaged (and then layer 2 with layer 2, and then layer 3 with layer 3.....all the way to layer 90 with layer 90. This method simultaneously did this for all 8192 grid cells (128 lines of longitude and 64 lines of latitude). At the end, I obtained 90 averages for each grid cell. :)
~Trav.~
-----Original Message-----
From: William Michels <wjm1 at caa.columbia.edu>
To: rain1290 <rain1290 at aim.com>
Cc: r-help <r-help at r-project.org>; r-sig-geo <r-sig-geo at r-project.org>
Sent: Sun, Apr 14, 2019 4:46 am
Subject: Re: [R] Creating a mean line plot

So you're saying rowMeans(cbind(matrix_a, matrix_b)) worked to obtain
your X-axis values?

Wild guess here, are you simply looking for:
colMeans(rbind(matrix_a, matrix_b)) to obtain your Y-axis values?

[Above assuming matrix_a and matrix_b have identical dimensions (nrow, ncol)].

--Bill

William Michels, Ph.D.


On Fri, Apr 12, 2019 at 11:09 AM rain1290--- via R-help
<r-help at r-project.org> wrote: