[R-sig-Geo] Selecting a range of longitudes and latitudes for plotting

r@i@1290 m@iii@g oii @im@com r@i@1290 m@iii@g oii @im@com
Wed Apr 24 18:15:43 CEST 2019


Hi Kay (and everyone),

Thank you very much for your reply! I tried your suggestion, but, unfortunately, the error persists when trying to plot the 140 data points (coming from the individual averages of each layer across each of the, in this case, 196 grid cells selected - i.e. the average of layer 1 across all grid cells, then the average of layer 2 across all grid cells, then the average of layer 3 across all grid cells.....all the way to the average of layer 140 across all grid cells - so, effectively, 140 values):
>plot(RCP1pctCO2cumulative,lonlat, type="l",col="green", lwd="3", xlab="Cumulative emissions (TtC)", ylab="One-day maximum precipitation (mm/day)", main="CanESM2")

"RCP1pctCO2cumulative" was created like this:
>RCP1pctCO2cumulative <- rowMeans(cbind(get, IPSL, IPSLMR, IPSL5, MIROC, HadGEM, MPI, MPI5, GFDL, GFDL5)) #To get means of each element of x-variables (Ttc carbon)

For example, "get" and the other x variables listed there, look like this:
>get
  [1] 0.00000000 0.00644777 0.01250601 0.01746194 0.02656210 0.03360072 0.04399755 0.05404601 0.06154399 0.07105423
 [11] 0.08315538 0.08925389 0.10060635 0.10833009 0.12196157 0.13730928 0.14890850 0.16087072 0.17361501 0.18310140
 [21] 0.19810085 0.21316248 0.22423607 0.23529990 0.24695577 0.26119599 0.27643532 0.28517213 0.29978970 0.31870887
 [31] 0.33418021 0.34585044 0.36071229 0.37379062 0.39324498 0.41099992 0.42437476 0.43643925 0.44687960 0.45864752
 [41] 0.48055932 0.49634662 0.50779009 0.52861303 0.54971600 0.56138206 0.57472491 0.59202033 0.60975420 0.63057494
 [51] 0.64653736 0.66088217 0.68168259 0.69649595 0.71363837 0.72988760 0.75010443 0.76776582 0.78613955 0.81099886
 [61] 0.82979667 0.84431553 0.86824787 0.88447672 0.89909577 0.92162514 0.94854647 0.96631038 0.98120815 1.00357985
 [71] 1.02769291 1.04733002 1.06585240 1.09083056 1.11592567 1.13627303 1.15866983 1.17941856 1.19748724 1.22012913
 [81] 1.24142718 1.26937973 1.29283488 1.31011736 1.33134723 1.36014366 1.38395822 1.40615380 1.42895305 1.45046842
 [91] 1.47504234 1.49920797 1.52142668 1.54559219 1.57354927 1.60000896 1.62449229 1.64506662 1.67100036 1.70185161
[101] 1.72964287 1.75235510 1.77455521 1.80183053 1.83121216 1.85619974 1.88188243 1.91002214 1.93333006 1.96133912
[111] 1.98944890 2.01225924 2.03804183 2.06614304 2.09558916 2.12400699 2.14846969 2.18011498 2.20532560 2.23031592
[121] 2.26106715 2.28796983 2.31954741 2.35274339 2.37794161 2.40643740 2.43963051 2.46948838 2.49733877 2.53035021
[131] 2.56229091 2.59265327 2.61934137 2.64592481 2.67754769 2.70779777 2.73824191 2.76880598 2.80077982 2.83057237 
Thanks, and I look forward to your response!

-----Original Message-----
From: Kilpatrick, Katherine A <kkilpatrick using rsmas.miami.edu>
To: rain1290 using aim.com <rain1290 using aim.com>
Cc: r-sig-geo using r-project.org <r-sig-geo using r-project.org>
Sent: Wed, Apr 24, 2019 10:59 am
Subject: Re: [R-sig-Geo] Selecting a range of longitudes and latitudes for plotting

Hi;
The reason you are getting that error message is you are trying to plot a 1 dimension array by a 2 dimensional array.
I think simply adding the argument  fun = mean to your extraction of the RCP1pctCO2Mean brick will solve the confusion. As you have it written you are extracting 196 grid cells  for all 140 layers ending up with a 2d array   latlon <- extract(RCP1pctCO2Mean, expansion, fun=mean) Should  give you 140 values in a 1d array that represent the average of the cells in the grid subset for each of the 140 layers in the brick.
Assuming of course that this is what you were after. I had to read between the lines a bit not knowing really how RCP1pctCO2cumulative was created -- other than it was precomputed and had a length of 140.
btw: Cellstats would give you the average of the nlayers at each of the 196 grid cells  eg. a 1 d array of 196.
Kay


On Apr 23, 2019, at 10:08 PM, rain1290--- via R-sig-Geo <r-sig-geo using r-project.org> wrote:
Hi there,
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:    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, 
    ... 
     .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")))
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:

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
I tried doing something like this to start:

expansion <- expand.grid(103:116, 3:16) #to specify a range of longitudes  and latitudes

    >lonlat <- 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")
 
But this yields the error:
    Error in xy.coords(x, y, xlabel, ylabel, log) : 
    'x' and 'y' lengths differ
If it helps, here are the dimensions of the new variables created:
    

dim(lonlat)

    [1] 196   140
    

dim(expansion)

    
    [1] 196   2

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?
Thanks, and any assistance would be greatly appreciated!
[[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo using r-project.org
https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=02%7C01%7Ckkilpatrick%40rsmas.miami.edu%7C59333f2be1214c2ef12f08d6c859dc6e%7C2a144b72f23942d48c0e6f0f17c48e33%7C0%7C0%7C636916685638215109&sdata=myKpQUhzVczqH4E4fXt%2FBOr6rPWjOW9rpdsy6RXLq%2Bc%3D&reserved=0



	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list