I have a data array, a
, shown below:
a <- structure(c(0.9984951, 0.9959022, 0.9888077, 0.9691369, 0.9110772,
0.001501177, 0.004070025, 0.010984665, 0.029266702, 0.075221083,
0.999987, 0.9999417, 0.9997387, 0.9988276, 0.9947208, 1.300713e-05,
5.829127e-05, 0.0002611903, 0.001169507, 0.005219817, 0.9999757,
0.9999152, 0.9997039, 0.9989658, 0.996382, 2.430024e-05, 8.481104e-05,
0.0002959571, 0.001032229, 0.003593514), .Dim = c(5L, 2L, 3L))
dim(a)
[1] 5 2 3
a
, , 1
[,1] [,2]
[1,] 0.9984951 0.001501177
[2,] 0.9959022 0.004070025
[3,] 0.9888077 0.010984665
[4,] 0.9691369 0.029266702
[5,] 0.9110772 0.075221083
, , 2
[,1] [,2]
[1,] 0.9999870 1.300713e-05
[2,] 0.9999417 5.829127e-05
[3,] 0.9997387 2.611903e-04
[4,] 0.9988276 1.169507e-03
[5,] 0.9947208 5.219817e-03
, , 3
[,1] [,2]
[1,] 0.9999757 2.430024e-05
[2,] 0.9999152 8.481104e-05
[3,] 0.9997039 2.959571e-04
[4,] 0.9989658 1.032229e-03
[5,] 0.9963820 3.593514e-03
I have another vector that is the same length as the first dimension of the data array:
b = c(-1, -0.5, 0, 0.5, 1)
Is there a way in r to plot the data so that I can get 3 separate plots (this number equals the third dimensions of the array and each plot has 2 lines on it (this number equals the second dimensions of the array). And each line is the second dimension values as the y axis and the vector b as the x-axis, so the first data block should be the first plot, and two columns indicate two lines, and each column is the y values, and the corresponding x values are included in the b vector. Thank you in advance for your help.
a
(dim(a)
)? It look's like your subsettinga
witha[5, 2, 3]
, but the output looks like it could beprint(a)
. - Ian Campbell