title: Selecting a range of latitudes and longitudes for plotting
body: <p>I am trying to select a range of latitude and longitudes (and all grid cells within that range) to plot y-axis values (precipitation) as a function of x-axis values (emissions) based on aggregating (averaging) each of those grid cells. Thus, let's say that I wanted to aggregate/average each of the values of these grid cells and plot this as a function x-axis values. The values already computed for each grid cell for the y-axis correspond to average precipitation and consist of 140 values per grid cell. So, the idea would be the average the first value of each grid cell, then the second value of each grid cell, then the third value of each grid cell.....all the way to value #140 of each grid cell. This would yield 140 values that would be plotted as a single line plot.  The variable containing these y-axis values is called "RCP1pctCO2Mean", which is 3-dimensional and has the following attributes:</p>
  
  <pre><code>class       : RasterBrick 
  dimensions  : 64, 128, 8192, 140  (nrow, ncol, ncell, nlayers)
  resolution  : 2.8125, 2.789327  (x, y)
  extent      : -181.4062, 178.5938, -89.25846, 89.25846  (xmin, xmax, ymin,  
  ymax)
  coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
  data source : in memory
  names       :   layer.1,   layer.2,   layer.3,   layer.4,   layer.5,     
  layer.6,   layer.7,   layer.8,   layer.9,  layer.10,  layer.11,  layer.12,  
  layer.13,  layer.14,  layer.15, ... 
  min values  : 0.5261063, 0.5625295, 0.5301681, 0.6019284, 0.5177065,  
  0.6775601, 0.5336965, 0.5213086, 0.5971723, 0.5305891, 0.5514522,   
  0.5481200, 0.4681806, 0.5437223, 0.5988844, ... 
  max values  : 113.13776, 114.50780,  94.93643, 100.35409, 102.65459, 
  101.80622, 104.95480,  99.17839, 104.68667, 119.48342, 100.60391, 
  108.91896, 104.38969,  99.35735,  99.30752, ... 
  
  dput(head(RCP1pctCO2ModelMean,5))
  structure(c(8.06056747436523, 7.75062637329102, 7.73271865844727, 
  7.65678634643555, 7.75580596923828, 8.74016799926758, 8.28938064575195, 
  8.10810775756836, 8.10339508056641, 7.86748199462891, 10.6165672302246, 
  11.057600402832, 11.9450210571289, 12.3012786865234, 12.1853874206543, 
  8.51755447387695, 9.16703491210938, 7.79627380371094, 7.53922271728516, 
  8.14367599487305, 7.83845596313477, 8.22455596923828, 8.21650848388672, 
  8.186181640625, 8.34122924804688, 9.1652702331543, 9.03225784301758, 
  9.04341430664062, 8.98676376342774, 9.0090087890625, 10.5393569946289, 
  11.1039672851562, 11.2379959106445, 11.333048248291, 12.0459312438965, 
  10.0039085388184, 9.90224914550781, 9.24856033325195, 9.26007308959961, 
  9.17901306152344, 9.55168991088867, 10.1229606628418, 10.4827072143555, 
  11.0505676269531, 12.1166931152344, 9.01049194335937, 9.39016952514648, 
  10.1307640075684, 9.67219467163086, 9.63750610351562, 8.14553070068359, 
  8.06989059448242, 7.88368453979492, 7.78139190673828, 7.76021575927734, 
  8.09026031494141, 8.47544021606445, 8.53607864379883, 9.07613296508789, 
  8.45474319458008, 9.91985092163086, 10.0807098388672, 9.90288009643555, 
  10.3433769226074, 10.349861907959, 11.2688484191895, 11.9406700134277, 
  12.0929878234863, 11.8347038269043, 10.4144630432129, 12.5179420471191, 
  13.8380874633789, 14.6360946655273, 14.0480010986328, 13.3910736083984, 
  9.96924514770508, 10.3363311767578, 10.7060684204102, 10.889599609375, 
  10.6653129577637, 10.5626991271973, 10.047868347168, 10.2751319885254, 
  10.8663063049316, 11.7612907409668, 8.94287414550781, 9.23690567016602, 
  8.96449661254883, 8.62908248901367, 8.30552215576172, 8.18369979858398, 
  7.69772872924805, 7.5989143371582, 7.7111930847168, 7.66501693725586, 
  10.2653533935547, 9.95307464599609, 9.71684875488281, 9.06423645019531, 
  9.75586776733399, 9.83898010253906, 9.89386901855469, 9.82217864990234, 
  9.5716667175293, 9.0698844909668, 9.32229309082031, 9.11556243896484, 
  8.89283828735352, 9.28563232421875, 9.30773696899414, 7.3968879699707, 
  7.93817901611328, 7.98456954956055, 7.95158386230469, 8.098583984375, 
  8.80923156738281, 8.49755935668945, 8.15531387329102, 8.46451263427734, 
  8.68563690185547, 8.89066619873047, 9.1489013671875, 9.33551254272461, 
  10.1721000671387, 11.0765029907227, 8.04215698242188, 8.19046478271484, 
  8.40826110839844, 8.67290573120117, 9.18575973510742, 8.3109245300293, 
  9.11093368530273, 9.81162109375, 9.86040802001953, 9.50505447387695, 
  10.5363166809082, 9.481689453125, 9.08926620483398, 9.52505798339844, 
  8.68244476318359, 8.98393630981445, 10.1831520080566, 10.5507629394531, 
  10.1666023254395, 9.69676284790039, 8.34152221679688, 8.42654571533203, 
  8.35252838134766, 8.00343780517578, 7.82494201660156, 9.53874359130859, 
  9.61768341064453, 9.41213912963867, 9.64521713256836, 10.2018295288086, 
  10.4372673034668, 10.2102493286133, 11.5178192138672, 10.6066253662109, 
  8.7693229675293, 10.0142112731934, 10.0218872070313, 9.85999298095703, 
  9.61988754272461, 9.6459342956543, 8.68394012451172, 8.94484100341797, 
  8.99103088378906, 9.28208084106445, 9.25485153198242, 9.43952713012695, 
  9.46648941040039, 9.29736251831055, 9.17809677124023, 9.15292205810547, 
  9.86052169799805, 9.73173980712891, 9.56215209960937, 9.07076568603516, 
  8.6406623840332, 9.93644332885742, 10.4607345581055, 10.7315849304199, 
  10.8101539611816, 10.7245536804199, 8.11333770751953, 8.19898986816406, 
  9.07229690551758, 8.52103500366211, 8.86794967651367, 13.8089904785156, 
  14.1628616333008, 14.1612731933594, 13.8391723632812, 13.4812423706055, 
  10.3034606933594, 10.3893714904785, 10.6155006408691, 10.7073356628418, 
  10.2250640869141, 10.7160522460937, 10.9937141418457, 11.4714202880859, 
  11.451326751709, 11.2873542785645, 10.1245864868164, 10.7054138183594, 
  11.2963111877441, 11.2652069091797, 11.1456642150879, 10.2463417053223, 
  10.7579162597656, 10.9033828735352, 10.8239326477051, 10.9808113098145, 
  9.11014785766602, 9.57601928710938, 9.13134765625, 8.95542297363281, 
  9.004345703125, 10.011986541748, 10.4038223266602, 10.7760765075684, 
  10.8257308959961, 11.1445190429687, 10.5380798339844, 10.2488784790039, 
  10.957502746582, 10.7088333129883, 10.6826118469238, 8.83894119262695, 
  9.23114776611328, 8.83077545166016, 8.79364471435547, 9.5740608215332, 
  9.49266204833984, 9.36201629638672, 8.86088562011719, 8.70853042602539, 
  8.84630584716797, 8.54691619873047, 9.06980133056641, 9.68758087158203, 
  10.2382141113281, 11.163306427002, 8.64593887329102, 8.68509368896484, 
  9.1695442199707, 9.96113128662109, 10.5646827697754, 10.6185249328613, 
  11.3931076049805, 11.984349822998, 12.3294868469238, 12.6237396240234, 
  9.07107849121094, 8.50119094848633, 8.165673828125, 8.46488571166992, 
  8.7583610534668, 9.64865646362305, 11.1105819702148, 11.4002655029297, 
  10.5027854919434, 10.1196365356445, 9.72924041748047, 10.009349822998, 
  10.326407623291, 9.36514053344727, 7.79587249755859, 9.68682708740234, 
  9.97370910644531, 10.053092956543, 10.0790946960449, 9.88732604980469, 
  8.5629150390625, 8.67814178466797, 8.62764282226562, 8.40693130493164, 
  8.43646850585938, 8.18491287231445, 8.28544006347656, 8.32042083740234, 
  8.37117156982422, 8.74075393676758, 10.0410667419434, 9.86564865112305, 
  9.83465423583984, 10.2372169494629, 10.6772819519043, 10.7158340454102, 
  11.1418548583984, 11.3801231384277, 12.3574913024902, 12.7044395446777, 
  10.933625793457, 10.1660957336426, 8.9215690612793, 9.42180328369141, 
  10.0563125610352, 10.6793243408203, 10.605298614502, 10.532593536377, 
  10.4527519226074, 10.4930633544922, 9.60543518066406, 9.36136474609375, 
  9.02150115966797, 8.90760498046875, 9.39027709960937, 11.475407409668, 
  11.8939018249512, 12.2665367126465, 12.3773796081543, 12.2639549255371, 
  12.1986907958984, 12.9296035766602, 14.6138290405273, 12.5118690490723, 
  11.1584533691406, 11.6089347839355, 12.184122467041, 12.7126617431641, 
  12.8846618652344, 12.7170280456543, 10.4427520751953, 11.0104148864746, 
  11.0574317932129, 10.7889305114746, 11.428002166748, 12.8730773925781, 
  13.0610855102539, 13.9772033691406, 14.7699234008789, 15.2759140014648, 
  11.0441619873047, 12.8132598876953, 13.1194686889648, 13.3944534301758, 
  13.439665222168, 11.8274314880371, 12.5198951721191, 13.1492401123047, 
  13.310026550293, 13.7720932006836, 10.7566696166992, 11.1153205871582, 
  10.8651023864746, 10.8898574829102, 11.1934638977051, 10.3416526794434, 
  10.3679290771484, 10.5599853515625, 10.4897705078125, 10.3551536560059, 
  10.7984680175781, 9.9300895690918, 9.24563140869141, 8.82577590942383, 
  8.11003036499023, 9.96226196289063, 10.2302505493164, 10.1707107543945, 
  9.78019790649414, 9.43962249755859, 11.1743797302246, 11.4034492492676, 
  10.9475212097168, 11.3065505981445, 11.3690071105957, 9.07691192626953, 
  8.84776763916016, 8.99648666381836, 9.46799697875977, 10.1394309997559, 
  9.5390739440918, 9.72808990478516, 10.1971199035645, 10.3575813293457, 
  10.6958648681641, 12.1900230407715, 11.986629486084, 12.139289855957, 
  12.308757019043, 12.2176116943359, 10.5569931030273, 10.2808883666992, 
  9.90982055664062, 9.57319793701172, 9.34677658081055, 9.55350112915039, 
  9.78641738891602, 10.0147956848145, 10.3079559326172, 10.7283164978027, 
  8.64087753295899, 8.30433197021484, 8.60956497192383, 8.60016937255859, 
  8.54900741577148, 9.71597595214844, 8.8296272277832, 8.63880462646484, 
  8.47726745605469, 8.84029846191406, 10.1157096862793, 9.88607330322266, 
  9.32783508300781, 9.36255416870117, 10.1161201477051, 11.8296203613281, 
  12.8728881835937, 13.2580642700195, 13.5822448730469, 14.2079498291016, 
  8.7088752746582, 8.82841796875, 9.62056427001953, 9.44509429931641, 
  8.63022689819336, 10.438533782959, 10.7936264038086, 11.1668098449707, 
  11.4698097229004, 11.6895088195801, 10.657413482666, 10.6490295410156, 
  10.6090156555176, 10.7308578491211, 10.2125785827637, 8.9413688659668, 
  8.8182373046875, 8.83381042480469, 8.8937255859375, 8.81535415649414, 
  9.55851669311523, 9.21836166381836, 9.18197784423828, 9.25029678344726, 
  9.27070083618164, 8.93240661621094, 8.90249099731445, 9.04313659667969, 
  9.20108184814453, 9.35103607177734, 10.5618942260742, 11.06572265625, 
  11.445832824707, 11.9180442810059, 11.9453758239746, 12.2584243774414, 
  11.9192649841309, 11.7775825500488, 11.8008255004883, 12.2185432434082, 
  9.08272094726562, 9.66560821533203, 9.48288192749023, 9.70498886108398, 
  9.56975555419922, 10.349006652832, 10.0300796508789, 9.5968864440918, 
  9.54965896606445, 9.00812759399414, 10.6454582214355, 10.7713653564453, 
  11.4645782470703, 11.8325187683105, 10.4740211486816, 9.41022796630859, 
  9.07474822998047, 8.61860656738281, 8.40045318603516, 8.653662109375, 
  9.65197830200195, 9.63723449707031, 9.51137924194336, 9.57775497436523, 
  9.69926528930664, 8.98936157226563, 9.40332794189453, 9.6757568359375, 
  9.79740600585938, 9.78034057617188, 10.2542152404785, 10.1619010925293, 
  10.3302688598633, 10.5525291442871, 10.7628135681152, 10.2399101257324, 
  10.7667839050293, 10.9936302185059, 10.8458152770996, 10.6235733032227, 
  9.24678955078125, 9.91125411987305, 9.86469879150391, 10.2658912658691, 
  10.1045028686523, 8.5959098815918, 8.49214401245117, 8.39304656982422, 
  8.6228157043457, 8.61747360229492, 8.91071395874024, 8.69116439819336, 
  8.56472625732422, 8.52434997558594, 8.64141616821289, 11.7017639160156, 
  12.3285125732422, 12.0996276855469, 11.056103515625, 10.7624618530273, 
  11.0327911376953, 12.0061622619629, 11.4006072998047, 10.8051193237305, 
  9.97594757080078, 10.138427734375, 10.6871589660645, 11.5516906738281, 
  12.4771171569824, 12.7644668579102, 9.02487182617188, 8.8429817199707, 
  9.50254135131836, 9.22763977050781, 8.60505981445312, 9.68806610107422, 
  9.77085647583008, 9.95944061279297, 10.3024574279785, 10.7512054443359, 
  8.78317031860352, 8.94360504150391, 9.19855346679688, 9.44350967407227, 
  10.2734016418457, 11.8314613342285, 12.4076805114746, 12.5829055786133, 
  12.3372856140137, 11.6992652893066, 8.82733459472656, 8.83338012695313, 
  9.01612014770508, 9.31243057250976, 9.52871017456055, 9.1939811706543, 
  9.20086669921875, 9.17466049194336, 9.3692512512207, 9.51042022705078, 
  9.55322723388672, 9.08766632080078, 9.01230697631836, 9.08840942382812, 
  8.89073867797851, 10.0157516479492, 9.88614654541016, 9.88927917480469, 
  9.89448471069336, 9.81435546875, 10.0982810974121, 10.8838890075684, 
  12.3737106323242, 12.0203163146973, 12.3476577758789, 8.12273559570312, 
  8.38578720092773, 8.5104736328125, 8.67580947875977, 8.8884521484375, 
  11.280297088623, 9.81758041381836, 9.12517623901367, 9.57337417602539, 
  9.93379745483398, 9.97190170288086, 9.9986442565918, 10.1007339477539, 
  10.368416595459, 10.8695823669434, 10.6418167114258, 10.1072540283203, 
  9.56202163696289, 10.1464050292969, 11.0315299987793, 15.5208480834961, 
  16.458154296875, 16.6033325195312, 16.9603851318359, 17.5446258544922, 
  11.6627197265625, 11.2967132568359, 11.0439735412598, 10.7337928771973, 
  10.724112701416, 10.414665222168, 10.1816375732422, 10.0053001403809, 
  10.0604530334473, 10.3831871032715, 12.5386772155762, 12.61123046875, 
  11.556861114502, 10.815104675293, 10.3798713684082, 12.8164276123047, 
  12.5301361083984, 12.1416007995605, 11.1006622314453, 10.5525985717773, 
  12.7033218383789, 13.5069030761719, 14.3273956298828, 14.1952850341797, 
  13.8862731933594, 11.5364295959473, 11.4725784301758, 11.4327659606934, 
  11.6338516235352, 11.9929733276367, 10.9388458251953, 10.3944259643555, 
  10.7864356994629, 10.4639877319336, 10.4192794799805, 10.584090423584, 
  11.0457565307617, 11.1049293518066, 11.2156471252441, 11.2940994262695, 
  11.5789703369141, 11.3852058410645, 11.312281036377, 10.8983863830566, 
  10.7498306274414, 11.648999786377, 12.1443000793457, 12.3075752258301, 
  12.4243774414062, 12.5793846130371, 9.53582992553711, 10.3421630859375, 
  10.6005973815918, 10.7018409729004, 10.1489151000977, 15.3236968994141, 
  16.6732727050781, 17.0259368896484, 16.9183380126953, 18.6379180908203, 
  11.5663963317871, 13.1421661376953, 15.772624206543, 15.2286743164063, 
  14.1305938720703, 10.4395881652832, 10.3302070617676, 10.3431907653809, 
  10.6234725952148, 10.6850440979004, 10.1355682373047, 10.7770133972168, 
  11.2220344543457, 11.121208190918, 10.9759727478027, 10.4280487060547, 
  11.4163436889648, 11.5880157470703, 11.367276763916, 11.7584564208984, 
  12.3622993469238, 12.8618209838867, 13.0096267700195, 12.7293991088867, 
  12.3698738098145, 13.4502487182617, 13.9361175537109, 14.3981384277344, 
  14.8455154418945, 14.7898071289063, 10.8285942077637, 11.0353393554688, 
  13.0554183959961, 11.4933654785156, 10.6509674072266, 12.3171768188477, 
  11.9701278686523, 11.7984405517578, 11.3652336120605, 11.2212104797363, 
  11.7747032165527, 12.0631629943848, 11.609635925293, 12.5300575256348, 
  12.5889640808105, 14.9442291259766, 15.244026184082, 15.1138778686523, 
  14.8327117919922, 14.0672607421875, 13.8624649047852, 14.0361633300781, 
  13.746142578125, 13.3890182495117, 12.7229309082031, 11.7338531494141, 
  12.4392601013184, 12.6126739501953, 12.3359680175781, 12.0300300598145, 
  13.0475494384766, 13.4870010375977, 13.1330673217773, 12.8889770507812, 
  11.5218353271484, 12.9545684814453, 12.6848930358887, 12.5185249328613, 
  12.1927146911621, 12.1243927001953, 13.6282653808594, 13.0329132080078, 
  14.021321105957, 12.7892906188965, 11.5679710388184, 12.4451988220215, 
  12.6035362243652, 12.8059692382812, 13.2598541259766, 14.1865646362305, 
  11.4154563903809, 12.0055801391602, 12.315015411377, 12.8833023071289, 
  13.0320266723633, 11.3923133850098, 12.2035797119141, 12.3115371704102, 
  12.4416717529297, 12.8906295776367, 11.4880004882812, 11.4702560424805, 
  11.063402557373, 11.520093536377, 11.4941116333008, 10.2884147644043, 
  10.4248268127441, 10.2943084716797, 10.4938522338867, 10.171199798584, 
  10.8181655883789, 10.7096382141113, 10.3980682373047, 9.85380783081055, 
  9.06302337646484, 11.087833404541, 11.297770690918, 11.4384208679199, 
  11.8333045959473, 12.6423866271973, 11.0677742004395, 11.1663566589355, 
  14.6535186767578, 12.696688079834, 11.9809646606445, 12.5395179748535, 
  13.5047088623047, 13.6589874267578, 13.3168762207031, 13.8064010620117, 
  13.2664398193359, 12.1466331481934, 11.7755020141602, 11.2214569091797, 
  11.967204284668, 13.3286544799805, 13.0230804443359, 12.4111663818359, 
  11.5664184570313, 11.507154083252, 10.7482841491699, 10.2523262023926, 
  10.5137763977051, 10.6416915893555, 10.925708770752, 12.1461143493652, 
  12.5572776794434, 13.0962661743164, 14.0371612548828, 15.6014785766602, 
  12.1392105102539, 12.4931434631348, 12.5056259155273, 12.1932655334473, 
  12.1573226928711, 12.3337669372559, 12.2943237304688, 12.3938110351563, 
  12.3535987854004, 12.2837997436523, 11.199015045166, 11.0299026489258, 
  11.4233680725098, 11.3639068603516, 10.776929473877, 15.9578018188477, 
  18.5940185546875, 16.6747985839844, 12.2459892272949, 11.7588233947754, 
  10.8550109863281, 9.30074844360352, 9.1522102355957, 9.23973083496094, 
  9.94997406005859, 21.4329086303711, 20.6476043701172, 20.4366928100586, 
  19.5227752685547, 18.6518371582031, 13.4605987548828, 13.7962448120117, 
  14.7393859863281, 14.0098480224609, 13.7022705078125, 13.8268768310547, 
  13.9131362915039, 14.1420150756836, 14.5985153198242, 15.3337585449219, 
  10.2976509094238, 10.6874450683594, 10.6152442932129, 10.3048629760742, 
  10.0026962280273, 10.8500930786133, 12.313077545166, 12.8156112670898, 
  12.4003845214844, 12.062833404541, 11.8806510925293, 11.9595237731934, 
  12.7401191711426, 13.2080368041992, 12.648217010498, 14.9934814453125, 
  16.2576446533203, 16.2247314453125, 15.6419891357422, 14.6681213378906, 
  10.2608001708984, 10.204532623291, 10.8466209411621, 10.8580635070801, 
  10.5870002746582, 12.5249855041504, 13.235661315918, 13.3415161132812, 
  13.2680938720703, 13.6001312255859, 10.9847831726074, 10.9526977539062, 
  12.1701835632324, 10.9867134094238, 9.62559356689453, 14.671305847168, 
  15.7670822143555, 16.5200897216797, 17.2838760375977, 18.5971923828125, 
  12.4218063354492, 11.5890487670898, 11.3723731994629, 11.5280731201172, 
  12.0742370605469, 11.0745147705078, 10.6635795593262, 10.507258605957, 
  10.358984375, 10.2047622680664, 11.231372833252, 11.1456260681152, 
  10.8480117797852, 10.3289199829102, 9.81418380737305, 13.1054672241211, 
  13.3634078979492, 13.6211837768555, 14.0335067749023, 13.8940582275391, 
  11.4586517333984, 11.3107444763184, 12.1839057922363, 11.6442543029785, 
  10.0313461303711, 11.5685440063477, 13.461506652832, 13.9238220214844, 
  12.9616546630859, 12.0961059570313, 15.3089569091797, 14.529133605957, 
  12.9434677124023, 11.6556198120117, 10.7868843078613, 13.7810775756836, 
  14.6285568237305, 14.3505905151367, 12.6306495666504, 11.0644081115723, 
  13.6406951904297, 13.0658325195313, 11.6025444030762, 10.8227111816406, 
  10.6873641967773, 14.1373397827148, 15.3703903198242, 16.4337646484375, 
  16.3727081298828, 16.0835571289062, 9.32263946533203, 9.81831588745117, 
  10.2201850891113, 10.4734298706055, 10.432006072998, 9.83030319213867, 
  9.97000503540039, 10.0799949645996, 10.1364440917969, 10.2572006225586, 
  11.0884750366211, 11.7081008911133, 11.6705154418945, 11.3407791137695, 
  10.8895950317383, 12.5218650817871, 14.0942642211914, 14.4718688964844, 
  13.89228515625, 13.6701507568359, 12.1981781005859, 12.0445930480957, 
  13.2136001586914, 12.3655586242676, 11.3412635803223, 12.4833915710449, 
  11.7754150390625, 11.693514251709, 12.1434707641602, 12.578157043457, 
  10.8240905761719, 10.6200454711914, 10.1548942565918, 9.93075942993164, 
  10.2509727478027, 15.1843124389648, 15.0255569458008, 14.8466598510742, 
  15.1112106323242, 16.322314453125, 13.0618423461914, 14.1408599853516, 
  13.0202850341797, 13.6123336791992, 14.1315383911133, 12.7721778869629, 
  12.7291236877441, 13.1240371704102, 13.9317779541016, 14.8634048461914, 
  11.2654998779297, 12.3573486328125, 13.258935546875, 12.5885932922363, 
  12.298176574707, 13.9735443115234, 14.5013107299805, 15.1036834716797, 
  15.3642013549805, 15.3964065551758, 11.2573120117187, 11.9989395141602, 
  12.0881286621094, 12.2077728271484, 12.2564170837402, 10.4119132995605, 
  10.5908760070801, 10.9370986938477, 10.9051147460937, 11.1913566589355, 
  12.3859100341797, 12.3887336730957, 13.8762435913086, 14.5053375244141, 
  14.3133880615234, 13.3645736694336, 12.5263206481934, 12.3438980102539, 
  12.354638671875, 13.1039337158203, 11.9940643310547, 11.8350044250488, 
  12.025373840332, 12.0098609924316, 12.8584075927734, 13.5398986816406, 
  13.7642166137695, 14.2189575195312, 14.8441345214844, 15.6326904296875,   
  14.128108215332, 13.0739379882812, 11.9704299926758, 11.3222679138184, 
  12.2943817138672, 13.596760559082, 13.6019485473633, 13.8898880004883, 
  14.744856262207, 15.6628112792969, 12.945686340332, 13.7123504638672, 
  ... 
   .Dim = c(10L, 140L), .Dimnames = list(NULL, 
  c("layer.1", "layer.2", "layer.3", "layer.4", "layer.5", 
  "layer.6", "layer.7", "layer.8", "layer.9", "layer.10", "layer.11", 
  "layer.12", "layer.13", "layer.14", "layer.15", "layer.16", 
  "layer.17", "layer.18", "layer.19", "layer.20", "layer.21", 
  "layer.22", "layer.23", "layer.24", "layer.25", "layer.26", 
  "layer.27", "layer.28", "layer.29", "layer.30", "layer.31", 
  "layer.32", "layer.33", "layer.34", "layer.35", "layer.36", 
  "layer.37", "layer.38", "layer.39", "layer.40", "layer.41", 
  "layer.42", "layer.43", "layer.44", "layer.45", "layer.46", 
  "layer.47", "layer.48", "layer.49", "layer.50", "layer.51", 
  "layer.52", "layer.53", "layer.54", "layer.55", "layer.56", 
  "layer.57", "layer.58", "layer.59", "layer.60", "layer.61", 
  "layer.62", "layer.63", "layer.64", "layer.65", "layer.66", 
  "layer.67", "layer.68", "layer.69", "layer.70", "layer.71", 
  "layer.72", "layer.73", "layer.74", "layer.75", "layer.76", 
  "layer.77", "layer.78", "layer.79", "layer.80", "layer.81", 
  "layer.82", "layer.83", "layer.84", "layer.85", "layer.86", 
  "layer.87", "layer.88", "layer.89", "layer.90", "layer.91", 
  "layer.92", "layer.93", "layer.94", "layer.95", "layer.96", 
  "layer.97", "layer.98", "layer.99", "layer.100", "layer.101", 
  "layer.102", "layer.103", "layer.104", "layer.105", "layer.106", 
  "layer.107", "layer.108", "layer.109", "layer.110", "layer.111", 
  "layer.112", "layer.113", "layer.114", "layer.115", "layer.116", 
  "layer.117", "layer.118", "layer.119", "layer.120", "layer.121", 
  "layer.122", "layer.123", "layer.124", "layer.125", "layer.126", 
  "layer.127", "layer.128", "layer.129", "layer.130", "layer.131", 
  "layer.132", "layer.133", "layer.134", "layer.135", "layer.136", 
  "layer.137", "layer.138", "layer.139", "layer.140")))
  </code></pre>
  
  <p>For the x-axis, I already have 140 values to be plotted. The x variable is called "RCP1pctCO2cumulative" and is 1-dimensional. Here are the values:</p>
  
  <pre><code>dput(RCP1pctCO2cumulative)
  c(0, 0.00697490638121963, 0.0139075990766287, 0.021697436273098, 
  0.0302329704165459, 0.0389980841428041, 0.0486239280551672, 
  0.0591636016964912, 
  0.0698652867227793, 0.0806971430778503, 0.0917696304619312, 
  0.102874741703272, 
  0.115288959443569, 0.127942492067814, 0.140930585563183, 0.154951927065849, 
  0.169483987987041, 0.18332038372755, 0.197460225224495, 0.211912712454796, 
  0.227608525753021, 0.243575794994831, 0.257900005578995, 0.273098181188107, 
  0.288984017074108, 0.305822652578354, 0.321933174133301, 0.338437202572823, 
  0.356079193949699, 0.373604437708855, 0.389580103754997, 0.406976979970932, 
  0.423514771461487, 0.440741804242134, 0.459019854664803, 0.477243804931641, 
  0.494844323396683, 0.511731442809105, 0.529583910107613, 0.54879242181778, 
  0.568029862642288, 0.587030050158501, 0.606201952695847, 0.626413214206696, 
  0.645859175920486, 0.66550235748291, 0.685490393638611, 0.705517685413361, 
  0.725719237327576, 0.74520371556282, 0.764879602193832, 0.78538470864296, 
  0.806885379552841, 0.827258145809174, 0.847640424966812, 0.869502395391464, 
  0.891108268499374, 0.912525850534439, 0.934271132946014, 0.956432664394379, 
  0.977902102470398, 0.999574398994446, 1.02313443422317, 1.0449088037014, 
  1.06765602231026, 1.09229186177254, 1.11614397168159, 1.13850414156914, 
  1.16062269210815, 1.18386173844337, 1.2078672170639, 1.23217906951904, 
  1.25505521297455, 1.27949770689011, 1.30394254922867, 1.32788743972778, 
  1.35124933719635, 1.37474408149719, 1.39838930368423, 1.42129179239273, 
  1.44566521644592, 1.47075144052506, 1.49397988319397, 1.51616193056107, 
  1.54051134586334, 1.56606665849686, 1.59053231477737, 1.61592463254929, 
  1.64096541404724, 1.66613935232162, 1.69049085378647, 1.71510955095291, 
  1.73991868495941, 1.76491104364395, 1.79114699363708, 1.81589571237564, 
  1.84101955890656, 1.864857172966, 1.8899533867836, 1.91575677394867, 
  1.9422261595726, 1.96840007305145, 1.99298502206802, 2.01899757385254, 
  2.04547454118729, 2.07122528553009, 2.09852977991104, 2.12717348337173, 
  2.15352830886841, 2.17984690666199, 2.20684263706207, 2.23266286849976, 
  2.25915194749832, 2.28647100925446, 2.31463184356689, 2.34280925989151, 
  2.36965861320496, 2.39779574871063, 2.42558825016022, 2.45266799926758, 
  2.48168079853058, 2.50962221622467, 2.53702754974365, 2.56574511528015, 
  2.59377150535583, 2.62192821502686, 2.6505597114563, 2.68051118850708, 
  2.70983340740204, 2.73927145004272, 2.76805067062378, 2.79780313968658, 
  2.8272668838501, 2.85747616291046, 2.88714888095856, 2.91689431667328, 
  2.94743349552155, 2.97868416309357, 3.00965495109558, 3.03861720561981
  </code></pre>
  
  <p>I tried doing something like this to start:</p>
  
  <pre><code>expansion &lt;- expand.grid(103:116, 3:16) #to specify a range of longitudes  
  and latitudes
  lonlat &lt;- extract(RCP1pctCO2Mean, expansion)
  
  plot(RCP1pctCO2cumulative, lonlat, type="l",col="green", lwd="3",  
  xlab="Cumulative emissions (TtC)", ylab="One-day maximum precipitation  
  (mm/day)", main="Test model")
  </code></pre>
  
  <p>But this yields the error:</p>
  
  <pre><code>Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' and 'y' lengths differ
  </code></pre>
  
  <p>If it helps, here are the dimensions of the new variables created:</p>
  
  <pre><code>dim(lonlat)
  
  [1] 196   140
  
  dim(expansion)
  
  [1] 196   2
  </code></pre>
  
  <p>What could I be doing wrong (the lengths appear to be the same)? Ultimately, the goal would be to plot the 140 values as a function of emissions (i.e. "RCP1pctCO2Mean" as a function of "RCP1pctCO2cumulative" once each of those selected grid cells are aggregated). The above works absolutely fine when just selecting "one" specific grid cell, but not an aggregate of grid cells. Is this possible to do for an aggregate of grid cells?</p>
  
  <p>Thanks, and any assistance would be greatly appreciated!</p>