What does it mean counts plot in self organizing maps - r

I'm using the som function from kohonen package and I'm using this tutorial as a guide.
som_model <- som(t(data_train_matrix),
grid=som_grid,
rlen=1,
alpha=c(0.05,0.01),
keep.data = TRUE,
n.hood= "circular")
plot(som_model, type="count")
I have a data of 31×1400 but when I'm trying to read the counts plot, it doesn't match the same quantity of samples (31). The plot I got gives me around 100 samples.
this is an example of my data
structure(c(-8691, 96233, 94318, 19206, 139453, 135652, 47782,
56190, -63139, 161452, 83268, 194879, -4112, 193153, -55742,
168244, -26043, 171304, 67181, -52147, -45487, 77098, 79648,
123380, -52991, 113980, -35812, 161776, -26874, 125046, 89662,
94537, 68053, 59601, 87972, 8844, 82108, 85343, 145252, 130751,
66224, 32792, 101576, 174156, 37090, 102740, 101521, 154264,
28431, 81740, 113085, 104153, 6385, 95860, 67247, 58344, 106147,
225375, -714, 212145, 51164, 24108, 33896, 128937, 182192, 5715,
94954, 198818, 127890, 272457, -45888, 96562, 15617, 22385, 102185,
154694, 93797, 55638, 118959, 184010, 6310, 54728, 141369, 209807,
140799, 100809, 93704, 198260, 264015, 271577, 90354, 125713,
112490, 103888, 186512, 178664, 30646, 100788, 194517, 197307,
-3709, 111675, 175022, 186898, 242656, 107932, 269935, 110129,
38492, 88179, 35392, 81003, 118482, 124713, 124830, 78896, 79962,
154348, 181855, 8146, 90599, 115869, 58740, 119922, 12046, 216180,
24770, 329719, 96091, 239658, 119638, 96020, 120758, 144941,
170427, 26691, 112377, 246679, 170131, 314849, 97399, 194975,
60680, 287463, 85241, 145845, 31902, 93297, 305020, 261229, 176675,
146127, 306958, 62111, 101310, 113621, 208697, 73762, 354256,
104883, 202739, 108740, 287507, 106152, 532421, 115689, 643646,
143442, 1026203, 130904, 1951723, 83570, 5818682, 289423, 5864851,
49296, 2369016, 184566, 1184562, 188584, 635480, 88563, 577216,
144760, 454805, 139133, 510350, 40305, 366688, 55486, 258099,
74080, 281519, 162968, 218759, 334500, 353090, 263008, 210560,
445832, 378725, 497266, 298151, 469138, 248365, 381608, 219821,
393548, 116469, 396907, 320685, 429351, 164311, 397822, 270935,
565860, 245619, 435443, 214331, 417268, 268967, 459714, 419833,
348551, 314194, 480522, 183062, 274876, 295398, 470877, 350616,
425871, 642579, 670075, 395643, 679445, 333423, 524843, 207011,
488471, 426073, 263541, 328925, 485258, 419273, 493798, 325854,
505041, 317356, 394418, 254990, 432610, 254212, 459642, 311613,
429672, 340076, 478631, 393919, 415449, 335445, 499644, 310914,
479802, 229937, 317058, 321625, 349939, 410056, 450019, 389055,
544372, 382828, 465619, 441888, 522416, 321660, 562040, 390768,
427916, 356081, 477152, 481436, 609419, 589189, 710624, 1167121,
1884282, 687543, 949401, 613100, 834546, 425695, 613319, 444637,
624192, 684646, 771698, 726366, 813694, 616384, 756803, 483736,
707427, 517319, 761253, 617534, 785160, 765434, 892135, 1057392,
1144724, 902210, 1114782, 1027470, 1488406, 1794285, 3202191,
1680875, 2378078, 1384652, 1942915, 1940959, 2753094, 8178326,
9296747, 17334234, 18341903, 4077766, 4757832, 12437987, 13770176,
5388983, 6043089, 3557519, 4344363, 3462297, 4193800, 3002130,
3751664, 2889390, 3596128, 2990671, 4052441, 4551441, 7645868,
6055792, 8720274, 11204851, 14342229, 13297134, 17421005, 16032135,
22046214, 33034409, 41895354, 134659124, 309713419, 54318759,
138429326, 21521670, 32507615, 31364480, 51975213, 41972208,
70888295, 96423383, 193962950, 127239777, 183865572, 184485432,
362581277, 266284997, 372142920, 254797938, 379524966, 168531540,
217593817, 109955151, 132909067, 45946711, 52766776, 39059161,
46851181, 36854510, 44138904, 42208748, 51775529, 30842738, 38044295,
34739365, 62307643, 35222394, 263589982, 19288663, 53574604,
22473059, 32180156, 15377680, 39229960, 14883020, 37024731, 26775128,
38438456, 31174328, 37159679, 20374102, 24638170, 18843009, 23709900,
16290335, 22019997, 13866224, 21410739, 13409806, 19807146, 12580394,
19423477, 12605523, 20175243, 11286325, 15895629, 12624149, 20150895,
15564663, 23173356, 13344234, 19144941, 16147475, 25059434, 16165655,
22543911, 17719126, 26056352, 25241362, 33870246, 20346030, 25373366,
27599769, 34874263, 19750731, 25488861, 17456089, 26803417, 21655991,
29032569, 18525780, 28589676, 28986493, 54330313, 30702160, 62741684,
36217696, 66746224, 37179427, 70384105, 32845869, 54067819, 40466477,
60334993, 47169915, 71194010, 64983410, 94329526, 107713258,
163970090, 205975485, 422860074, 727019292, 1894177881, 1536778649,
2595541011, 1325315247, 1724342395, 623772789, 933707256, 520787992,
763760597, 484959955, 762351348, 544836917, 814960223, 557751071,
825802985, 484106551, 727516034, 320419472, 473245904, 215986703,
319460038, 176355114, 258972369, 147044357, 203777597, 93349619,
132506190, 89329707, 120091964, 56028958, 73913976, 39160835,
57805430, 31597040, 45502763, 24996502, 38369765, 23164619, 34974560,
23446564, 36260730, 24240365, 37462383, 24380634, 38464790, 23825674,
38232189, 24261678, 40822263, 22545025, 37662136, 25969748, 41828554,
25342961, 41373278, 28190579, 51622837, 40721443, 89715709, 33899480,
63713905, 33879100, 82571628, 33194622, 63495601, 40899580, 83115054,
52391035, 119897472, 43331860, 85516401, 40972806, 111409364,
45229140, 86017237, 60769699, 114219430, 76387165, 153804973,
100612861, 166584932, 119025540, 209322137, 125258469, 215257202,
126370047, 181489720, 114200659, 190602759, 98391103, 165094932,
82887335, 170246121, 62767360, 159226407, 53772778, 144576214,
56504793, 178803162, 54720435, 176147058, 43853977, 160656487,
40490358, 127145028, 46175432, 125716299, 47970998, 142990986,
32686143, 96639106, 28256535, 113010719, 32245717, 109662077,
49315728, 158277164, 39866932, 133740008, 29835677, 121148901,
24484676, 101192015, 20524807, 79615303, 19472158, 67957180,
17802439, 57347318, 17393829, 46409063, 21637835, 57425134, 24685542,
64142491, 22664706, 52782681, 18106352, 45773357, 17952323, 35943518,
22782703, 48608934, 29545983, 54107623, 20658150, 35173101, 19308973,
30420232, 21648523, 33358523, 34925054, 57821290, 23749536, 52300713,
22246131, 51411073, 29970764, 49549669, 28882978, 45160688, 23305717,
42669741, 22496477, 42017707, 24123603, 37571652, 27087406, 46212322,
31957832, 67751755, 31735687, 44207281, 31518232, 39656499, 44331797,
66592574, 305051402, 236738335, 61016620, 351951034, 47694378,
54296987, 57684704, 62552739, 72834978, 76647987, 77661681, 90054910,
94027736, 105247183, 94705645, 118623817, 127635699, 168214213,
125541816, 183982552, 158891836, 202074988, 154380584, 202356268,
156180324, 227847605, 151802781, 210993781, 103866998, 140327139,
91144468, 146060827, 78798545, 172226188, 94375043, 184702914,
59593981, 111951306, 48128719, 67660907, 58181026, 63873729,
58155047, 64229300, 59114829, 66547475, 51011422, 59659321, 40733341,
48214428, 48326348, 55047638, 37896199, 42305785, 31219727, 37677791,
36206563, 45170766, 30796703, 39213659, 29426202, 38564819, 31122601,
41869397, 30150284, 39687478, 30251942, 41245534, 36266084, 50365634,
42078213, 72001066, 38470907, 60095827, 45098881, 67795094, 32427023,
43091370, 44211158, 69249130, 46198628, 72272292, 42080483, 59575435,
67142635, 78404256, 91590826, 91367080, 81279600, 97189859, 159178282,
145226665, 64489072, 69171662, 107042650, 117525720, 71536249,
91016903, 55757027, 135642542, 41353460, 72293186, 68166846,
222105000, 29394948, 73100483, 40777925, 101079557, 29585737,
75349492, 25111702, 36658070, 20004139, 30107908, 17352754, 24086411,
16352644, 23340098, 15867984, 21918125, 15447299, 22444804, 15101802,
21772688, 28749939, 41991543, 18181681, 25302101, 15872482, 22007830,
18623139, 27740895, 27122497, 38924843, 15959970, 23381320, 19605220,
25139255, 20045670, 24677277, 17806558, 25316488, 17454866, 24929439,
21039898, 27983508, 26828223, 37740624, 24913259, 41158419, 37691892,
82078166, 39765574, 105437749, 39806713, 92607859, 36546145,
79750166, 31341108, 76242765, 22884050, 66475659, 17116842, 41957883,
12610875, 20866546, 11422645, 18295880, 11426134, 16997562, 10421891,
16780423, 9952551, 15942561, 9597599, 16154386, 9345908, 15026048,
8971600, 15287752, 8630352, 14028149, 8972152, 13734295, 9210456,
15206966, 8586592, 14676163, 9113002, 15707156, 8724114, 14789908,
9653042, 14574939, 10636733, 15123006, 10884812, 15665015, 16096044,
31557043, 50665144, 69162457, 40125003, 67033492, 88178064, 117506119,
48467438, 62147370, 48550396, 64970507, 28885550, 33953693, 14804984,
21215748, 13263821, 19255188, 11543123, 16023682, 11155710, 13600438,
13419212, 15819226, 11648329, 14025008, 15381219, 15881212, 18821434,
23967947, 11387648, 12943318, 13650064, 17002021, 9341178, 11791878,
7537499, 9877936, 7424723, 9225182, 7303770, 9539660, 7533521,
9356114, 7445487, 9183369, 7723960, 10046696, 7069531, 8696718,
6883109, 8408871, 6576015, 8175139, 6292912, 7827066, 6193985,
7618591, 6092437, 7463851, 8007993, 9628431, 8214867, 9592375,
5643731, 7108804, 7796140, 9073715, 7786279, 9218450, 5852014,
7220848, 5531071, 6707757, 5325259, 7057039, 5144619, 6276074,
4919355, 6112982, 4642040, 5895631, 4766331, 5898431, 4372028,
5764096, 4425480, 5700040, 4791509, 5677859, 4351727, 6068910,
4356586, 7292655, 6665298, 7799927, 6460052, 8712420, 8969410,
13822499, 38495765, 43424278, 39621419, 44732021, 37841957, 45142206,
34591715, 41608581, 36228112, 45347955, 35407558, 39870269, 25625081,
28832164, 28159583, 30823422, 36269127, 36764400, 33333975, 33608379,
33903467, 37356045, 49753141, 51095775, 36042304, 39506987, 40017888,
40858778, 33928722, 31665538, 35496066, 34854597, 36648303, 34853318,
40974424, 37693597, 37355103, 37254712, 40888929, 39220835, 46749102,
45365054, 38692171, 38994526, 37071537, 38250689, 30771455, 30199810,
30860932, 32031393, 26897069, 27840729, 33115398, 30062000, 37198082,
34015339, 31362599, 34999206, 30190111, 29543583, 37835112, 33625379,
36564345, 32805001, 33423060, 27516038, 27951644, 25433845, 28747171,
29462452, 37615549, 32462563, 36596022, 35115114, 32025505, 33817468,
28993647, 27627406, 32829876, 29419615, 28088898, 28000767, 25990459,
25452615, 28452616, 22908176, 80282537, 44883045, 48061766, 31887840,
26450990, 22957308, 21324193, 21018404, 21640103, 21695803, 20979613,
20553114, 22796444, 21646388, 28102885, 25637043, 46302294, 30639089,
78909133, 63895259, 924877222, 574298446, 61682541, 69381555,
36784559, 44112668, 35770403, 39446356, 40450488, 46573911, 36409794,
36249387, 32861168, 33681605, 27772410, 28078711, 22718664, 21390343,
20514355, 20727964, 18684570, 18747393, 17864735, 18478176, 17042677,
18099092, 21912916, 23904073, 23854075, 25437678, 28012160, 27610597,
28921222, 27998643, 38371840, 38347990, 29883020, 31254336, 28944013,
28106503, 22333477, 25509381, 37523067, 44624151, 51398284, 51326151,
45237494, 48676641, 48884986, 36137123, 48455452, 50305940, 34113506,
30096213, 47848045, 50180241, 29558817, 27433066, 23156895, 30452971,
47913798, 81310397, 21173499, 36507223, 16705783, 44526670, 16915890,
27976765, 39421477, 97994802, 18089480, 46748560, 19213895, 68914899,
18327982, 25978185, 22752008, 26705144, 23232643, 37060652, 49410882,
115207125, 35668038, 100482133, 32216745, 37102054, 26936190,
37952923, 29880600, 59994902, 17154364, 36879989, 16187604, 18481243,
36345076, 36791199, 34979093, 33833615, 35171628, 30291521, 18008813,
18242520, 35924017, 34838177, 31498662, 30227506, 20756740, 18249859,
15655526, 16252234, 13366295, 13884202, 12628160, 12998964, 36134899,
31894894, 38682499, 42236948, 174659159, 161098060, 19201111,
23133845, 15768300, 23803944, 15563058, 21015488, 12400951, 15170894,
14463083, 15372174, 14145159, 13432976, 12508976, 14533641, 12603315,
14752532, 29165535, 34701841, 34613004, 38382305, 12701108, 15299177,
10542043, 11814855, 12720299, 14503320, 13262320, 16774322, 10999137,
13968885, 12477166, 14675299, 11295054, 14260493, 8920837, 10540879,
10821060, 12680480, 7308803, 8518389, 8708401, 9690657, 7360906,
8333873, 7872593, 9331100, 14983661, 20052686, 7071602, 8167268,
6752306, 7607500, 7300664, 8251348, 10283979, 10793896, 8633848,
9200107, 7047555, 7782679, 7026706, 8085627, 7037919, 8680326,
10692618, 11052656, 11815421, 14029510, 11321528, 11017049, 11148373,
12237342, 10273471, 10712920, 10930483, 9380573, 10664164, 9876970,
13067421, 9311465, 10683709, 8063691, 7772941, 5590061, 6222425,
4846499, 5578634, 4242595, 5323003, 3907435, 4659877, 3810184,
4686749, 3530004, 4106660, 3572372, 4192119, 3723871, 3911411,
3725753, 3844458, 3938543, 4354640, 4345201, 5141553, 4971951,
6759012, 6429379, 9578618, 8903225, 15996240, 14592373, 33416266,
30327576, 87368361, 86730343, 116182636, 147896821, 50987865,
66104255, 21879816, 25754860, 11882765, 13454804, 7726892, 8477395,
5837996, 6149962, 4994890, 5079621, 4383296, 4387098, 4258400,
4099896, 3964729, 3877924, 3337955, 3353870, 3603645, 3658213,
3117322, 3254205, 3400425, 3487749, 3909460, 3903053, 4335854,
4256376, 3558737, 3873069, 4237518, 4184615, 3879568, 4033895,
4166573, 4595958, 4272930, 4539149, 4873247, 4683438, 6452743,
7393386, 7265479, 12181806, 6763889, 7661375, 6971519, 6047856,
6438627, 5386490, 5686910, 4848516, 5979046, 4854495, 5753200,
4628045, 4952361, 4710863, 4565250, 4561258, 5486697, 5536561,
4411443, 4537075, 4755574, 4706289, 5164482, 5076590, 5073376,
7646303, 5311173, 10917625, 4101964, 5068857, 4337606, 5115597,
4564387, 4668824, 4631901, 5467250, 4723013, 5798968, 5869221,
7572800, 7765647, 10084591, 9597208, 11138673, 15000598, 15929891,
15296224, 14624702, 18227523, 16894466, 16357620, 18928804, 23857201,
26463772, 15077118, 19689309, 28562776, 38402739, 31931912, 44236189,
37961974, 47425417, 47120253, 82298168, 117287497, 147415427,
105762156, 132902413, 118794694, 148980103, 66277231, 66976258,
47955638, 59812110, 42280110, 47196037, 37788708, 38700275, 24178459,
22981247, 32673089, 32218495, 18744666, 16737281, 11989656, 10980265,
8226540, 7846527, 5285698, 4718877, 3719617, 3816493, 3296615,
3337248, 3349739, 3234481, 2725805, 3040272, 2784791, 2834818,
2905428, 3418362, 3323803, 3547666, 3424843, 2993907, 2991925,
3190753, 3698424, 3207622, 3041379, 3391014, 3548188, 3830123,
2794684, 3171099, 2976888, 3409152, 2609357, 3076370, 3448181,
3477913, 2395924, 3008964, 2935119, 2503567, 2747312, 3003776,
2345180, 2887543, 2875523, 4047590, 3544112, 3356890, 2872637,
2801455, 3385894, 2895361, 3228398, 2974132, 3224779, 2755368,
2956570, 2778855, 2732627, 2535518, 2924457, 2712460, 2918495,
2988522, 2940121, 2910417, 2799566, 2634529, 2843051, 2638672,
2841214, 2506761, 2569948, 2651799, 2272136, 2412711, 2200321,
2512456, 1782598, 2444849, 1586675, 2115228, 1662123, 2141720,
1365500, 2291167, 1541416, 2250852, 1614926, 2097689, 1651982,
2224546, 1476782, 2110319, 1613876, 2129865, 1684429, 2368080,
1842319, 2484362, 1823977, 2267909, 1636541, 2482010, 1506425,
2201026, 1704055, 2406874, 1754001, 2693560, 1958744, 2487501,
1786765, 2647321, 1762151, 2506832, 2146423, 2569078, 1847711,
2571620, 1971076, 2857411, 1825205, 2860939, 1694570, 2900597,
1658465, 3454193, 2452289, 24374736, 2562823, 27360760, 1530087,
4774473, 2406990, 18455112, 3438796, 43025599, 1892972, 5540505,
1987491, 3729814, 1960989, 3339258, 1826160, 3126293, 1841758,
3202876, 1975889, 3140266, 1784067, 2711450, 1759820, 2772621,
1890299, 2798137, 1713928, 2681236, 1810850, 2695869, 1982948,
2696095, 2046829, 2834138, 2032780, 2776086, 1883856, 2792566,
2038178, 2667824, 2516633, 2671938, 2434678, 2777007, 2121305,
3218425, 2393865, 4534850, 3026273, 3532661, 2508045, 3782342,
2733001, 3722022, 2053139, 2918697, 2583343, 3507402, 3628020,
3558825, 4760942, 4080084, 3503204, 3744204, 2564623, 3456410,
3033733, 4347196, 4794716, 9519405, 39264539, 129542795, 31952500,
90506566, 5440410, 10940205, 6986735, 42102411, 6807691, 18738039,
5727356, 6646276, 6334260, 7106678, 27528625, 25385670, 12503497,
10349194, 16741591, 15880339, 22913289, 23861758, 16395721, 20257989,
27227267, 24764297, 10987688, 9991612, 14836286, 14178754, 15889351,
15068307, 19056688, 19893617, 13550093, 74537094, 17046564, 64156917,
16928452, 18709071, 7970680, 8679154, 21885172, 16677500, 11086138,
10347864, 5777681, 6511858, 10702080, 8263870, 6414862, 5177301,
7392801, 5522991, 7632363, 5521891, 4429442, 5141246, 4437962,
4713124, 4682656, 5201962, 3357663, 4033730, 6347157, 4536040,
5162888, 5858457, 4530111, 5514569, 3705917, 4395069, 4005062,
4322744, 4137568, 4509432, 4568026, 4917769, 4246884, 4752821,
4101506, 4794941, 4716765, 5100793, 5251493, 5487365, 5151850,
5539515, 5329484, 5979635, 5693495, 6431739, 5551617, 6137586,
6717681, 7579966, 8287942, 9944413, 7973593, 9539309, 6260445,
6944790, 6639264, 7017903, 8661446, 8890185, 7452330, 7076329,
8065504, 7758935, 12986285, 12510351, 14687851, 16016589, 10811421,
10505975, 16936125, 16048723, 14235022, 14692536, 11515410, 10185673,
12366240, 10845984, 11628100, 11152221, 12104536, 12209379, 11897270,
11660802, 13841182, 10864520, 15370625, 10895724, 14362926, 9628075,
16481124, 10886762, 21453723, 11848232, 27491072, 15788705, 43149552,
33719668, 30596535, 27402730, 55715731, 36420718, 42660840, 40643469,
26369805, 20993226, 17688010, 15372860, 13853568, 10276320, 14987013,
10451967, 11915948, 8664789, 7948947, 6767177, 6562650, 5540239,
6098262, 4965553, 8351472, 5203208, 7635639, 5066968, 9317502,
5508798, 9179550, 5908849, 8243336, 5041237, 7386454, 5545817,
8637649, 5760011, 8217680, 6006850, 21881677, 12726606, 45508424,
36954717, 19157445, 23446346, 36113612, 23161366, 32250763, 30897388,
21136706, 16206069, 30222602, 19291662, 16714054, 14372993, 15650123,
10796328, 17412825, 15672118, 18807737, 17917709, 15503508, 10081708,
11417608, 7923077, 10699799, 7749773, 14386948, 9261257, 56467667,
33417304, 52890449, 48032293, 29062872, 23242018, 36501486, 25065587,
23412523, 20826889, 19066199, 13908736, 10945865, 8582446, 12192383,
6659470, 15113489, 6820906, 7424753, 5668608, 6933959, 5670777,
6195668, 5768035, 10875709, 8193418, 7811554, 11609960, 7010878,
6137633, 12463110, 12057172, 6545448, 7732166, 7126985, 6395963,
14712971, 7478643, 16245271, 11206575, 8742793, 7826046, 10455331,
6923893, 7973865, 7164603, 8153317, 7577606, 9840250, 9746034,
14425877, 26246565, 54367548, 122538954, 26109680, 40166089,
11137275, 12810374, 8641624, 9622083, 6658394, 6728764, 10523876,
6634422, 6649192, 5785925, 6190257, 5878080, 10275940, 5990167,
6047874, 19281908, 7720276, 89801987, 4375955, 12655641, 4618788,
6776033, 6682859, 6004507, 4902971, 4857628, 5543398, 4571978,
4709011, 4301051, 6197798, 7274294, 6679755, 7558111, 4087772,
4809747, 3439387, 4404121, 3981186, 4155907, 4893781, 6083104,
4977023, 6429334, 4893516, 5824296, 14311515, 20325943, 12896349,
14917987, 5651188, 5331369, 4977180, 5787633, 4094555, 4877837,
5385169, 4938339, 5704021, 5788051, 6524867, 5104170, 5125587,
4480038, 4361553, 3857693, 5522122, 4442797, 6018572, 4736688,
8359507, 5533513, 26298661, 16836405, 9494794, 12965025, 15970044,
9261835, 12597059, 12515509, 11531908, 7522031, 25978385, 15344807,
17410087, 16188748, 23840369, 15386360, 26054572, 18904748, 14266842,
12893861, 6265884, 6181915, 10717623, 6973572, 11438989, 11864686,
15902082, 10367689, 12820533, 10140250, 6767399, 5794777, 8072540,
4987108, 4407985, 4579671, 3894191, 4071378, 3300006, 3446009,
4659237, 3550968, 5111119, 3934388, 4529638, 3633981, 4401070,
3305972, 3788658, 2815157, 4379994, 2563102, 3526197, 2799465,
3371079, 2612031, 3395443, 2879536, 3167921, 3445117, 2728494,
3387837, 2777852, 4002138, 3191039, 4896911, 3064223, 3744857,
2882676, 2902579, 3192018, 3020582, 3389213, 3445934, 3991864,
3692447, 7492313, 5699982, 19672453, 10839706, 265562556, 143875100,
37315909, 46713627, 10699275, 8801800, 7451853, 7942848, 7310364,
7842462, 6046960, 6140278, 6196309, 6506569, 5342634, 5545833,
4889793, 5176057, 4779892, 5297344, 3807013, 4127983, 4305286,
4807368, 3347352, 3570671, 2987449, 3389652, 2997169, 3208945,
2894681, 3166850, 3108300, 3487693, 5614301, 6082539, 6426602,
7359362, 6252190, 7040382, 3762828, 3877266, 3362161, 3465711,
3401599, 3465280, 7227293, 6262747, 13237754, 12960688, 10409922,
8986292, 22737209, 20786940, 10695245, 11105227, 20328453, 18559200,
15286621, 16834838, 10300064, 10545877, 6270455, 6778050, 5363202,
5383261, 5010046, 5296460, 3995311, 4354900, 2590026, 3069099,
2618467, 2975881, 2437062, 2793579, 2326570, 2529690, 2170797,
2789567, 2404439, 2458120, 2523752, 2489057, 2821219, 2815891,
2334835, 2120994, 2075297, 2148385, 2051080, 2071283, 2018314,
2112460, 2251169, 1845515, 1970813, 2018929, 1746810, 1834591,
1841811, 1851426, 1970003, 1779241, 1941810, 1777824, 2109186,
1774234, 2030660, 1765702, 1858116, 1778271, 1917918, 1785178,
1828023, 1608377, 2865573, 2450871, 2389475, 1880194, 2051307,
1727171, 2902959, 2174825, 2415768, 1962911, 2516672, 2145713,
2006572, 1896725, 1994148, 1866227, 2054433, 1652913, 1645923,
1772884, 2738784, 2259827, 1719877, 2384452, 1766685, 8205262,
2198165, 69853478, 3131797, 8033983, 3482429, 3243942, 41344297,
2362982, 11974176, 2233809, 2933079, 1896241, 1910444, 1533542,
1626105, 1584269, 1696223, 1336963, 2446058, 1672874, 1844127,
1491734, 1350359, 1308638, 1239937, 1088673, 1174309, 1058759,
1568335, 1360706, 2408198, 2071746, 3011886, 2385974, 2004130,
1624216, 2493848, 1818031, 2713902, 2849376, 1720433, 1543522,
4498393, 3350395, 1777060, 2614621, 2080426, 1562895, 1902742,
2330395, 1106693, 1284215, 1076838, 859232, 1088411, 809099,
1660226, 1387403, 962019, 892591, 699096, 820620, 672778, 978114,
762233, 588511, 685934, 703018, 1317503, 835060, 740301, 683674,
596679, 840375, 790465, 868156, 654120, 577653, 701434, 896742,
645360, 703156, 600585, 673209, 628230, 701949, 555575, 650786,
554766, 507645, 581107, 639615, 562741, 698161, 666114, 749345,
395458, 598941, 569225, 495801, 453205, 510450, 536268, 486821,
341256, 577687, 512912, 594426, 785059, 845732, 4600127, 3115079,
24186388, 21174502, 11207431, 11143093, 23510245, 21492747, 4962912,
6832719, 1254627, 1343449, 6037434, 4468585, 32044645, 28029382,
10078353, 10943453, 21016001, 18035347, 19715190, 20921866, 1665130,
1850215, 685908, 666779, 500121, 529365, 543014, 453104, 723921,
728066, 541418, 573654, 251205, 429521, 228239, 483925, 210967,
549936, 403591, 426226, 321299, 274720, 403122, 442367, 366499,
408785, 327629, 526714, 272867, 442841, 207223, 488989, 100714,
442116, 311411, 338482, 634560, 231571, 864007, 663464, 414986,
693304, 215624, 348521, 214632, 247313, 284767, 380655, 335655,
302782, 237952, 234741, 119118, 290922, 56938, 228415, 145593,
229541, 79279, 219851, 114883, 229190, 253440, 231830, 298345,
343361, 659553, 583089, 5661473, 4763641, 42501347, 37465706,
19046469, 19515752, 1678340, 1700477, 666387, 699187, 570783,
576521, 418374, 314371, 330738, 240459, 280430, 291783, 270997,
164393, 213340, 257488, 204183, 251663, 143228, 231753, 314947,
284795, 462774, 463102, 655267, 557190, 992314, 626150, 281850,
270902, 218983, 228705, 205245, 127646, 177902, 265351, 531852,
483171, 504113, 533657, 178571, 399556, 429216, 341907, 339516,
547767, 302428, 524955, 259506, 303736, 298121, 279209, 705637,
839540, 1892941, 2688194, 832135, 1224368, 499247, 689864, 561686,
411460, 401568, 376855, 389534, 381450, 324276, 270848, 253953,
360355, 153729, 142692, 182576, 215206, 26731, 131634, 121065,
279575, 8378, 354559, 3350890, 6042431, 731897, 1303240, 299307,
269394, 188308, 372369, 93559, 394179, 165682, 569932, 282164,
333632, 150821, 308888, 1788277, 3701803, 216357, 334917, 133974,
148063, -19306, 217085, -40842, 186624, 99943, 272404, 161389,
356429, 203508, 193395, 36872, 232185, 95510, 134201, 52049,
190583, 180666, 270383, 351192, 559072, 99377, 176959, 80716,
287869, 94236, 158161, 271578, 79586, 12655, 160936, 168816,
284199, 173465, 189205, -46341, 50435, 129964, 191754, 83231,
56092, 25193, 162338, 107541, -22639, 55217, 35787, 47909, 63362,
53623, 98341, 84343, 83148, 68525, 281156, 200815, 325498, 7023,
211971, 147348, 173311, 131772, 82241, 57698, 55677, 125820,
75611, 141190, 206538, 121937, 132452, 109561, 285020, 288524,
161788, 218752, 339620, 376737, 461421, 788267, 629020, 1200393,
1242008, 2462325, 2464638, 3344975, 3831304, 2510363, 3074276,
1173759, 1533410, 627920, 818287, 440831, 576747, 280345, 389708,
339139, 383207, 146265, 193118, 199649, 245270, 192506, 139053,
200213, 102594, 191376, 166123, 146673, 525440, 160612, 141108,
214046, 163549, 81501, 89169, 229145, 149189, 127803, 224104,
43046, 62199, 100512, 64995, 182381, 223371, 227468, 152893,
188902, 161563, 271719, 180982, 195312, 132571, 185243, 204,
190690, 42928, 260847, 86701, 266180, 101212, 432107, 84562,
912283, 58893, 2052785, 149812, 2087275, 109099, 1221562, 212146,
505035, 155971, 366796, 208734, 274636, 157009, 220756, 39843,
123336, 140177, 51948, 85997, 186316, 159521, 73779, 142105,
233432, 163863, 103808, 213311, 175274, 122588, 223116, -70881,
51806, 95016, 199224, 129689, 16215, 14954, 83282, -58656, 64609,
-37894, 75890, 81202, 25216, -57565, 4882, 223007, -104123, -6556,
111613, 1972, 29788, 78473, 38631, 41930, 7173, -87043, 16431,
42437, 40524, 75041, -47853, -24668, -83193, 97270, 93566, -64184,
-53851, 72846, 81179, -88798, -85487, 93245, 99034, -53903, 48958,
-11602, 61371, 76051, 161268, 73033, -120141, 17482, 71106, 871,
55534, 7786, -36060, 49042, -9883, 40971, -3269, 12172, -17860,
174429, 66996, 16702, 105242, -110576, 106180, -7294, -158111,
55265, 29837, 57985, -38040, 60157, -15124, -94016, 17030, -61063,
-92350, -56016, -31862, -2691, -34232, -151965, -80909, -85343,
112232, 2900, -62024, -44420, 82929, 80607, 26812, -851, -116838,
-100528, 60697, 112403, -144841, -22094, 1512, -21703, -62315,
-173280, -5621, -5223, -138151, -18163, 107855, -46407, -831,
140759, -5251, -101338, 15117, 22505, -159721, 38653, 75320,
-18872, 49405, -50979, 37787, -84577, 91876, -56425, 82390, 46025,
-27861, -35438, -10174, -26542, -95622, -115634, 83964, -128186,
47685, -53810, 10099, 97387, 3935, 7213, -200517, 22792), .Dim = c(2L,
1406L))

The reason you have fewer items (samples) in the plot is that kohonen clusters items that are sufficiently similar. Consider the data set wines from the package. It has 13 variables for 177 wines, but the count plot shows 25 clusters. It also shows how many wines are in each cluster by the color gradient.
library(kohonen)
data(wines)
kohmap <- xyf(scale(wines), classvec2classmat(wine.classes),
grid = somgrid(5, 5, "hexagonal"), rlen=100)
plot(kohmap, type="counts", labels = wine.classes, col = wine.classes + 1, main = "count plot")

Related

How to use for loop to save multiple plots?

For each driver, I want to create and save a plots$MixtureModelPlot png plot. It returns ggplots.
If I only want one plot, it would be:
plots <- MethylMix_PlotModel("MGMT", MethylMixResults, METcancer)
plots$MixtureModelPlot
plots$CorrelationPlot
However, when I want to plot all the drivers, my code below returns an empty plot.
for (gene in MethylMixResults$MethylationDrivers) {
png(file = paste(gene, '.png', sep = ''))
plots[gene] <- MethylMix_PlotModel(gene, MethylMixResults, met.kirp, METnormal = met.normal)
plots[gene]$MixtureModelPlot
plots[gene]$CorrelationPlot
dev.off()
}
Data:
> dput(drivers)
c("A2ML1", "ABCA4", "ABCC12", "ABHD1", "ACRBP", "ACSL5", "ACSM5",
"ACSS3", "ACVRL1", "ADH1C", "ADRB2", "AEBP1", "AFMID", "AIF1",
"AIM2", "AKR1B10", "AKR1C4", "AKR7L", "ALDH3B2", "ALDH8A1", "ALDOC",
"ALOX5AP", "ALPK3", "AMFR", "ANKRD2", "ANKRD22", "ANKRD45", "ANXA8L2",
"ANXA9", "AOC3", "APBB1IP", "APH1B", "APOBEC3C", "APOL3", "APOL4",
"APOM", "APP", "AQP1", "ARFRP1", "ARHGAP29", "ARHGDIB", "ARL11",
"ARL4D", "ARRDC3", "ASCL3", "B3GNT3", "B3GNT8", "BAMBI", "BAZ2B",
"BCHE", "BCL2L14", "BCL2L15", "BHMT", "BIN2", "BIRC7", "BRF2",
"BSCL2", "BST2", "C10orf116", "C10orf140", "C10orf82", "C10orf99",
"C11orf53", "C11orf63", "C11orf70", "C11orf92", "C12orf34", "C13orf23",
"C14orf109", "C15orf54", "C16orf55", "C17orf64", "C1QTNF3", "C1orf114",
"C1orf116", "C1orf168", "C1orf229", "C1orf38", "C1orf54", "C1orf88",
"C2", "C20orf114", "C20orf118", "C20orf151", "C21orf56", "C2orf43",
"C2orf65", "C3AR1", "C3orf67", "C4orf33", "C6orf132", "C7orf41",
"C8orf55", "C8orf56", "C8orf84", "C9orf125", "C9orf152", "C9orf25",
"C9orf41", "CALML5", "CAMK2G", "CAPG", "CAPN8", "CAPS", "CASC1",
"CASP4", "CCDC19", "CCDC8", "CCR2", "CD101", "CD200", "CD248",
"CD28", "CD4", "CD48", "CD68", "CD69", "CD9", "CD93", "CDC42BPG",
"CDC42SE1", "CDCA2", "CDK2", "CDK3", "CFP", "CGB2", "CHD7", "CHRNB1",
"CIAPIN1", "CKMT1B", "CLCNKB", "CLDN1", "CLDN23", "CLDN3", "CLDN7",
"CLDN8", "CLEC1A", "CLEC2B", "CLIC2", "CMAH", "CMTM3", "CNKSR1",
"CNTN6", "COX7A1", "COX7B2", "CP", "CPN2", "CPNE5", "CREB3L2",
"CRYBB1", "CSF2RB", "CT47B1", "CTLA4", "CTSF", "CTSS", "CTSZ",
"CXorf61", "CYP4Z2P", "DACT1", "DACT2", "DAPP1", "DBNDD1", "DCAF12L1",
"DDR2", "DDX43", "DEF6", "DEM1", "DFNA5", "DISP1", "DLEC1", "DNALI1",
"DNASE1", "DOPEY2", "DQX1", "DSEL", "DUSP7", "ECHDC2", "ECHDC3",
"EFCAB4A", "EFCAB4B", "EFEMP2", "EFS", "EHF", "ENG", "ENO3",
"EPHA4", "EPHX1", "ERMP1", "ESRP2", "ETV7", "EVC2", "EXPH5",
"EXTL1", "FAM108C1", "FAM124B", "FAM176B", "FAM25A", "FAM55D",
"FAM71D", "FAM83A", "FAM83C", "FBXL21", "FBXO27", "FBXO4", "FCAMR",
"FER1L5", "FERMT1", "FERMT2", "FES", "FGFR4", "FGG", "FHL1",
"FITM1", "FKBP1B", "FLJ44606", "FLVCR2", "FOXS1", "FURIN", "FUT2",
"FUT3", "FXYD3", "FXYD4", "FZD4", "GALNT3", "GAS1", "GBP6", "GGT6",
"GIMAP2", "GIMAP6", "GIPC2", "GJB5", "GJB6", "GJC2", "GLB1L",
"GLRB", "GLTP", "GNPNAT1", "GPC4", "GPR109B", "GPR143", "GPR152",
"GPR172B", "GPR182", "GPR77", "GPR84", "GPSM3", "GPT", "GSDMB",
"GYPC", "H1F0", "HAAO", "HCG4", "HECA", "HEY2", "HHLA2", "HIGD1B",
"HKR1", "HLA-B", "HLA-DPA1", "HNRNPA3P1", "HORMAD2", "HOXA11",
"HOXA11AS", "HOXA3", "HOXA4", "HOXA5", "HOXA7", "HOXB2", "HOXB6",
"HOXB9", "HOXC8", "HOXD10", "HOXD3", "HOXD4", "HOXD8", "HOXD9",
"HP", "HRG", "HS3ST1", "HSD17B14", "HSD17B7P2", "HSPB3", "HSPB9",
"HTATIP2", "HYAL1", "IFFO1", "IFI16", "IFI27", "IFITM1", "IFITM2",
"IFITM5", "IGFBP4", "IKZF3", "IL12RB2", "IL1F5", "IL1RL1", "INO80E",
"IRS1", "ISG20L2", "ITGA5", "ITGB2", "ITIH5L", "KCNJ1", "KHK",
"KIAA0494", "KIAA1826", "KIAA1949", "KISS1", "KLF2", "KLHDC7B",
"KLHL17", "KNG1", "KRT13", "KRT19", "KRT20", "KRT23", "KRT7",
"KRT8", "KRTAP4-8", "KRTCAP3", "LAMB3", "LAMC2", "LAT", "LCTL",
"LDHAL6A", "LEAP2", "LGALS12", "LGALS4", "LGALS7", "LGALS7B",
"LHX1", "LIME1", "LIPC", "LOC100133893", "LOC134466", "LOC144776",
"LOC149837", "LOC25845", "LOC284837", "LOC339535", "LOC391322",
"LOC400931", "LOC440563", "LOC441666", "LOC441869", "LOC554202",
"LOC642587", "LOC645166", "LOC728264", "LPXN", "LRG1", "LRRC34",
"LRRN4", "LY6G6C", "LY75", "MACC1", "MAGEA1", "MAGEA10", "MAGEB6",
"MAL", "MAP1A", "MAP4K5", "MAPKBP1", "MCCD1", "MFNG", "MFSD2A",
"MGP", "MICAL2", "MMP13", "MMP19", "MS4A1", "MS4A13", "MSL3L2",
"MTMR9L", "MUC20", "N4BP2L1", "NAA11", "NAPRT1", "NAPSB", "NARFL",
"NAT8", "NAT8B", "NBL1", "NDRG1", "NINL", "NKAPL", "NLRP1", "NOSTRIN",
"NPL", "NR0B2", "NRSN2", "NUDT12", "NUDT4", "ODAM", "OLFML1",
"OR13A1", "OSM", "OVOL1", "PAGE1", "PAGE3", "PAPLN", "PARVG",
"PCDH10", "PCDHB8", "PDCD1LG2", "PDE1A", "PGD", "PHF11", "PIK3CG",
"PIWIL2", "PKN3", "PKP3", "PLCB4", "PLEK", "PLIN2", "PLIN4",
"PLLP", "PLOD3", "PLS1", "PLS3", "PNMA3", "POF1B", "POGK", "PON3",
"PPFIBP2", "PPP1R3D", "PRB3", "PRKAG3", "PRKY", "PROM2", "PRPH2",
"PRSS38", "PSCA", "PSMA2", "PTPN22", "PTPN6", "PTPN7", "PWWP2B",
"ProSAPiP1", "RAB25", "RAB34", "RAPSN", "RASSF10", "RBM23", "RBP3",
"RBP4", "RBP5", "RDH5", "REC8", "REG4", "REM2", "RFTN2", "RHOF",
"RMND1", "RNASE1", "RNASE2", "RNF122", "RPL39L", "RRAD", "RRN3P1",
"RSPH9", "RTP4", "RXFP4", "S100A16", "S100B", "S100P", "SAMD9",
"SCNN1A", "SDR42E1", "SDR9C7", "SEPX1", "SERP2", "SERPINA3",
"SERPINB9", "SFN", "SFRS16", "SFT2D3", "SH2D1A", "SH3BGRL2",
"SHC1", "SIGIRR", "SLAMF7", "SLC10A6", "SLC12A3", "SLC15A2",
"SLC16A5", "SLC22A2", "SLC23A2", "SLC26A7", "SLC2A10", "SLC34A2",
"SLC35E2", "SLC39A5", "SLC45A3", "SLC47A2", "SLC5A1", "SLC5A6",
"SLC7A8", "SLC9A1", "SLC9A11", "SLC9A3R2", "SLFN12", "SLURP1",
"SMAD7", "SMAGP", "SMEK3P", "SNCG", "SOCS2", "SOX15", "SOX9",
"SPAG6", "SPATA18", "SPINK1", "SPINK8", "SPN", "SPTBN2", "SRRM1",
"STAP1", "STAT5A", "STOM", "SULT1C4", "SYPL2", "TACSTD2", "TAGAP",
"TBX2", "TBX3", "TCEA3", "TCN1", "TEAD2", "TEAD3", "TFEC", "TFF1",
"TFPI", "TGFBR3", "TGM1", "THRSP", "THY1", "TIE1", "TIFAB", "TINAG",
"TKT", "TLR1", "TMEM139", "TMEM220", "TMEM25", "TMEM40", "TMEM71",
"TMEM88", "TMEM98", "TMPRSS12", "TMPRSS2", "TNF", "TNFAIP6",
"TNFRSF6B", "TNFRSF9", "TNFSF10", "TOMM70A", "TP63", "TRAM2",
"TREML4", "TRIB2", "TRIL", "TRIM14", "TRIM29", "TRIM61", "TRIM63",
"TRIM9", "TRIP13", "TRPV6", "TSPAN8", "TSPYL3", "TUBA3C", "TYRP1",
"UBD", "UBE2DNL", "UGT3A1", "ULK2", "UOX", "UPK1A", "UPK1B",
"USH1C", "USHBP1", "USP46", "VCX2", "VCX3A", "VCX3B", "VENTXP1",
"VILL", "VNN1", "WBSCR26", "XCL2", "XIST", "ZDHHC23", "ZFP3",
"ZFP82", "ZG16B", "ZIK1", "ZMYND10", "ZNF135", "ZNF154", "ZNF208",
"ZNF215", "ZNF233", "ZNF234", "ZNF238", "ZNF280A", "ZNF433",
"ZNF454", "ZNF501", "ZNF542", "ZNF544", "ZNF572", "ZNF577", "ZNF586",
"ZNF620", "ZNF660", "ZNF662", "ZNF664", "ZNF667", "ZNF679", "ZNF69",
"ZNF714", "ZNF716", "ZNF763", "ZNF788", "ZNF790", "ZNF814", "ZNF844",
"ZP1", "ZSCAN12")
Since your function returns a list of ggplot objects, you need to plot these inside your loop:
for (gene in MethylMixResults$MethylationDrivers) {
png(file = paste(gene, '.png', sep = ''))
plots[gene] <- MethylMix_PlotModel(gene, MethylMixResults, met.kirp, METnormal = met.normal)
plot(plots[gene]$MixtureModelPlot)
plot(plots[gene]$CorrelationPlot)
dev.off()
}
In interactive mode (i.e. when directly writing e.g. plots[gene]$MictureModelPlot on the R command prompt) you can omit the plot() call because R auto-prints the value (and printing a ggplot plots it). But inside a loop auto-printing does not happen. You can see the same when working with any other values; for instance, compare:
a = 1
a
with
for (i in 1 : 5) {
a
}
The first code snippet will print the value of a. The second code snippet won’t because a is used as part of a compound statement rather than on its own on the command prompt.

Getting date to appear on x axis of plot.stl method in R

I was wondering if anyone knows of a way to get the dates to appear on the x axis of an stl plot.
res<- (stl(ts(data[,variable],frequency=52,start=as.Date(data[1,date]) ),s.window="per",robust=TRUE) )
plot(res)
However this is just producing some unicode labels at the bottom of the chart, I have also tried chaning as.Date to as.character however this didn't work.
dput of some data:
structure(c("2007-01-01", "2007-01-08", "2007-01-15", "2007-01-22",
"2007-01-29", "2007-02-05", "2007-02-12", "2007-02-19", "2007-02-26",
"2007-03-05", "2007-03-12", "2007-03-19", "2007-03-26", "2007-04-02",
"2007-04-09", "2007-04-16", "2007-04-23", "2007-04-30", "2007-05-07",
"2007-05-14", "2007-05-21", "2007-05-28", "2007-06-04", "2007-06-11",
"2007-06-18", "2007-06-25", "2007-07-02", "2007-07-09", "2007-07-16",
"2007-07-23", "2007-07-30", "2007-08-06", "2007-08-13", "2007-08-20",
"2007-08-27", "2007-09-03", "2007-09-10", "2007-09-17", "2007-09-24",
"2007-10-01", "2007-10-08", "2007-10-15", "2007-10-22", "2007-10-29",
"2007-11-05", "2007-11-12", "2007-11-19", "2007-11-26", "2007-12-03",
"2007-12-10", "2007-12-17", "2007-12-24", "2007-12-31", "2008-01-07",
"2008-01-14", "2008-01-21", "2008-01-28", "2008-02-04", "2008-02-11",
"2008-02-18", "2008-02-25", "2008-03-03", "2008-03-10", "2008-03-17",
"2008-03-24", "2008-03-31", "2008-04-07", "2008-04-14", "2008-04-21",
"2008-04-28", "2008-05-05", "2008-05-12", "2008-05-19", "2008-05-26",
"2008-06-02", "2008-06-09", "2008-06-16", "2008-06-23", "2008-06-30",
"2008-07-07", "2008-07-14", "2008-07-21", "2008-07-28", "2008-08-04",
"2008-08-11", "2008-08-18", "2008-08-25", "2008-09-01", "2008-09-08",
"2008-09-15", "2008-09-22", "2008-09-29", "2008-10-06", "2008-10-13",
"2008-10-20", "2008-10-27", "2008-11-03", "2008-11-10", "2008-11-17",
"2008-11-24", "2008-12-01", "2008-12-08", "2008-12-15", "2008-12-22",
"2008-12-29", "2009-01-05", "2009-01-12", "2009-01-19", "2009-01-26",
"2009-02-02", "2009-02-09", "2009-02-16", "2009-02-23", "2009-03-02",
"2009-03-09", "2009-03-16", "2009-03-23", "2009-03-30", "2009-04-06",
"2009-04-13", "2009-04-20", "2009-04-27", "2009-05-04", "2009-05-11",
"2009-05-18", "2009-05-25", "2009-06-01", "2009-06-08", "2009-06-15",
"2009-06-22", "2009-06-29", "2009-07-06", "2009-07-13", "2009-07-20",
"2009-07-27", "2009-08-03", "2009-08-10", "2009-08-17", "2009-08-24",
"2009-08-31", "2009-09-07", "2009-09-14", "2009-09-21", "2009-09-28",
"2009-10-05", "2009-10-12", "2009-10-19", "2009-10-26", "2009-11-02",
"2009-11-09", "2009-11-16", "2009-11-23", "2009-11-30", "2009-12-07",
"2009-12-14", "2009-12-21", "2009-12-28", "2010-01-04", "2010-01-11",
"2010-01-18", "2010-01-25", "2010-02-01", "2010-02-08", "2010-02-15",
"2010-02-22", "2010-03-01", "2010-03-08", "2010-03-15", "2010-03-22",
"2010-03-29", "2010-04-05", "2010-04-12", "2010-04-19", "2010-04-26",
"2010-05-03", "2010-05-10", "2010-05-17", "2010-05-24", "2010-05-31",
"2010-06-07", "2010-06-14", "2010-06-21", "2010-06-28", "2010-07-05",
"2010-07-12", "2010-07-19", "2010-07-26", "2010-08-02", "2010-08-09",
"2010-08-16", "2010-08-23", "2010-08-30", "2010-09-06", "2010-09-13",
"2010-09-20", "2010-09-27", "2010-10-04", "2010-10-11", "2010-10-18",
"2010-10-25", "2010-11-01", "2010-11-08", "2010-11-15", "2010-11-22",
"2010-11-29", "2010-12-06", "2010-12-13", "2010-12-20", "2010-12-27",
"2011-01-03", "2011-01-10", "2011-01-17", "2011-01-24", "2011-01-31",
"2011-02-07", "2011-02-14", "2011-02-21", "2011-02-28", "2011-03-07",
"2011-03-14", "2011-03-21", "2011-03-28", "2011-04-04", "2011-04-11",
"2011-04-18", "2011-04-25", "2011-05-02", "2011-05-09", "2011-05-16",
"2011-05-23", "2011-05-30", "2011-06-06", "2011-06-13", "2011-06-20",
"2011-06-27", "2011-07-04", "2011-07-11", "2011-07-18", "2011-07-25",
"2011-08-01", "2011-08-08", "2011-08-15", "2011-08-22", "2011-08-29",
"2011-09-05", "2011-09-12", "2011-09-19", "2011-09-26", "2011-10-03",
"2011-10-10", "2011-10-17", "2011-10-24", "2011-10-31", "2011-11-07",
"2011-11-14", "2011-11-21", "2011-11-28", "2011-12-05", "2011-12-12",
"2011-12-19", "2011-12-26", "442573", "452832", "452785", "459228",
"479509", "477631", "465619", "462001", "485567", "462381", "456059",
"457401", "474094", "468766", "456945", "539126", "545640", "511801",
"486619", "484430", "481428", "470622", "479677", "486755", "477617",
"483656", "497479", "493436", "480080", "481527", "516029", "532349",
"503939", "472171", "461550", "504532", "489715", "480032", "488376",
"470772", "467395", "488155", "455712", "474456", "471237", "482943",
"459320", "456956", "465056", "461930", "441201", "451255", "464508",
"449199", "455411", "476323", "521761", "513416", "521070", "497596",
"485461", "485593", "461148", "429938", "441207", "459484", "462099",
"469285", "454395", "456729", "469251", "517727", "526719", "477985",
"484538", "469766", "472399", "481162", "479039", "481071", "485068",
"462108", "459079", "452410", "488574", "502166", "504323", "514529",
"524206", "504315", "462935", "461899", "461551", "455491", "456857",
"443314", "454586", "458943", "450555", "454311", "442808", "440126",
"414876", "415787", "413352", "423864", "448319", "415440", "431948",
"433313", "448509", "436400", "454154", "454183", "447735", "452220",
"451433", "472808", "446767", "426595", "463693", "435673", "452704",
"456828", "465069", "448685", "457353", "443859", "463972", "480139",
"493342", "500982", "529602", "527365", "512005", "484585", "455007",
"470006", "477522", "443956", "459038", "488877", "466669", "476242",
"470862", "457298", "466438", "454062", "460216", "466645", "445113",
"457255", "451553", "451504", "447991", "435100", "416140", "481390",
"489041", "496984", "486245", "478191", "455201", "448085", "459097",
"480859", "490248", "462523", "489755", "468391", "460229", "481276",
"472845", "481099", "476435", "487314", "475043", "476847", "461928",
"483488", "479379", "456732", "461538", "480773", "471101", "459898",
"482129", "464356", "459420", "457850", "456764", "438152", "467928",
"464732", "458767", "470256", "449488", "433263", "428548", "435099",
"429163", "424251", "434723", "425841", "399498", "418791", "405051",
"385037", "425144", "418296", "397644", "414283", "431907", "429117",
"424862", "439664", "432791", "443588", "434985", "442418", "445760",
"449290", "451412", "456247", "444372", "441390", "458192", "456435",
"450670", "447609", "439083", "464513", "462784", "439423", "450857",
"442374", "447753", "440207", "435254", "430841", "437233", "426523",
"430127", "431305", "470244", "508878", "511064", "504182", "462076",
"452218", "426535", "436892", "459008", "441449", "438783", "427497",
"432275", "436745", "423068", "429574", "416074"), .Dim = c(261L,
2L))
The problem is with how you have created the time series object.
?ts will give you
start : the time of the first observation. Either a single number or a
vector of two integers, which specify a natural time unit and a
(1-based) number of samples into the time unit.
Since your data starts at 2007-01-01 and is a weekly data, you have to specify c(2007,1), Note that the "1" here denotes that data start from the 1st week of 2007, as the data is weekly. Here the frequency should be set to 52 because, after 52 cycles/weeks a year will change from 2007 to 2008.
This should work
res<- (stl(ts(data[,2],frequency=52,start=c(2007,1 )),s.window="per",robust=TRUE) )

Getting graphical spikes in ggplot2

I'm trying to plot a simple graph that show the increase in wealth for two different investment strategies. When using the standard graph from R it works, but when I try to use ggplot2 I get these weird spikes in the lines.
Does any have any idea what could be causing this?
I've tried to simply the code as much as possible:
For the standard graph
ind.ts = ts(cbind(ind.passive,ind.active), start=c(insample.endstart,1),frequency=12)
plot(log(ind.ts),type="lines", col=c("blue","red"))
legend(x="topleft", legend=c("Passive","Active"), col=c("blue","red"), lty=1)
For the ggplot graph
testers=data.frame(ind.ts)
ggplot(testers, aes(date)) +
geom_line(aes(y = log(ind.passive), colour = "Passive",size="1")) +
geom_line(aes(y = log(ind.active), colour = "Active",size="1"))
The Ind.ts data set
structure(c(1, 1.026669, 1.066102329621, 1.09764083483818, 1.13073909657189,
1.17422279926966, 1.201650295415, 1.24229131005623, 1.24436842112664,
1.29675757602449, 1.29281154272065, 1.34840890311535, 1.37447769243928,
1.42187380670767, 1.43432089001159, 1.44828830683852, 1.47037760009442,
1.50663270057995, 1.51269991046518, 1.44617893190248, 1.47609892782461,
1.55880475075062, 1.60230787373457, 1.72267003659376, 1.6884336922865,
1.7947931958647, 1.80827747714523, 1.73407842742553, 1.83823238001199,
1.94879470474019, 2.03637158997651, 2.19836698633073, 2.07500122615881,
2.18823196806907, 2.11573803119891, 2.21303659177769, 2.25083083069207,
2.27667036862841, 2.44006700098487, 2.56495939036328, 2.59127330874902,
2.54554769994283, 2.64902166839781, 2.62135793511473, 2.24229384954953,
2.38534322797539, 2.58003017155629, 2.73574015247005, 2.89313822640227,
3.01496249083961, 2.92082933195062, 3.03735873897812, 3.15584610338566,
3.08028252428619, 3.25121048184135, 3.15027015001163, 3.13383204036887,
3.04763285626648, 3.24152630621501, 3.30661615444381, 3.5011906754359,
3.32628169286315, 3.26271977599422, 3.58162126961968, 3.47465973202375,
3.4018482373392, 3.48660188432426, 3.43296051433394, 3.64465402445034,
3.45302176049876, 3.43920276741325, 3.16710336206381, 3.18321124976327,
3.29673729577483, 2.9957319937214, 2.80662641161774, 3.02543381329387,
3.04403720581181, 2.97111425050939, 2.94227958670819, 2.75683358891715,
2.53472102032527, 2.58379068455775, 2.78122846592754, 2.80549468429276,
2.76500859050373, 2.71079783207832, 2.81360212906206, 2.64401226073284,
2.62324090041252, 2.43641368348514, 2.24723834303094, 2.26148583412576,
2.01595857860056, 2.19346574740491, 2.32192606890168, 2.18514140418268,
2.12856372294559, 2.09571359900937, 2.1165869064555, 2.29149953181808,
2.41150994529845, 2.44221328992199, 2.48518647497146, 2.53301388868229,
2.50620193667058, 2.64742390960003, 2.6698343529948, 2.80897010046677,
2.86115795596334, 2.89979789415863, 2.85611823847891, 2.81197121886675,
2.84980347964538, 2.90496997540435, 2.80930350417434, 2.81972040156782,
2.85016210302314, 2.89418855702854, 3.00999951213804, 3.11183381563269,
3.03729294841303, 3.09892873421517, 3.04396923311387, 2.98710484387007,
3.08097760069353, 3.08499827646243, 3.20047593194697, 3.16912086924169,
3.19575099190593, 3.14371138275373, 3.25904157854143, 3.26071346687123,
3.3485896948034, 3.35499219829987, 3.3971510302637, 3.44342702159796,
3.34200432210381, 3.3473849490624, 3.36955802696499, 3.4464479715823,
3.53637269205683, 3.65311189099431, 3.71864871831875, 3.7710110109214,
3.82954087282191, 3.75144504580245, 3.79450413203817, 3.96444479409563,
4.09921609487092, 4.03197255405065, 3.90887240000293, 3.96507025849778,
4.11298323942078, 4.18000430130714, 4.00202389816178, 3.973681564915,
3.73688988046171, 3.6132997214452, 3.59812747591486, 3.77562310430174,
3.82238042082541, 3.50029900180582, 3.47233161278139, 3.52122551422096,
3.20811814149644, 2.67119786498117, 2.47785656351383, 2.50381211101664,
2.29590056094204, 2.04999813136234, 2.23149881591877, 2.44744541933286,
2.58359925545577, 2.59022877114527, 2.78828284344458, 2.88774646903593,
2.99667515359443, 2.94310059519847, 3.1174675330616, 3.17829867703423,
3.06610473373492, 3.15882374088307, 3.34981254190434, 3.40448483240076,
3.13064849939144, 2.96722864772321, 3.17659630110655, 3.0311907820197,
3.30193068028814, 3.42901538831107, 3.42659107443153, 3.65581631094671,
3.74411158648869, 1, 1.026669, 1.066102329621, 1.09764083483818,
1.13073909657189, 1.17422279926966, 1.201650295415, 1.24229131005623,
1.24436842112664, 1.29675757602449, 1.29281154272065, 1.34840890311535,
1.37447769243928, 1.42187380670767, 1.43432089001159, 1.44828830683852,
1.47037760009442, 1.50663270057995, 1.51269991046518, 1.44617893190248,
1.47609892782461, 1.55880475075062, 1.60230787373457, 1.72267003659376,
1.6884336922865, 1.7947931958647, 1.80827747714523, 1.73407842742553,
1.83823238001199, 1.94879470474019, 2.03637158997651, 2.19836698633073,
2.07500122615881, 2.18823196806907, 2.11573803119891, 2.21303659177769,
2.25083083069207, 2.27667036862841, 2.44006700098487, 2.56495939036328,
2.59127330874902, 2.54554769994283, 2.64902166839781, 2.62135793511473,
2.24229384954953, 2.2509042579318, 2.25833224198298, 2.39462710945113,
2.53239958556629, 2.63903386731532, 2.55663795191, 2.6586375796394,
2.76235103162114, 2.69620929852, 2.84582464870417, 2.75747033083585,
2.74308185064955, 2.66763064126559, 2.83734797029354, 2.89432191753704,
3.06463539645259, 2.91153540595201, 2.85589887587967, 3.13503728790702,
3.04141253434097, 2.97767973468385, 3.05186564759377, 3.00491269460554,
3.19021063591839, 3.02247255089243, 3.01037661574376, 3.02584995154869,
3.04040428981563, 3.05344762421894, 3.06587515604951, 3.07715757662378,
3.08709679559627, 3.09641982791897, 3.10543040961822, 3.1145293207184,
3.12325000281641, 3.13012115282261, 3.13575537089769, 3.14064714927629,
3.14507546175677, 3.14941566589399, 3.15395082445288, 3.15865021118131,
2.96826256970236, 2.97253686780273, 2.97675787015501, 2.98092533117323,
2.98494958037031, 2.98900911179961, 2.99295460382719, 2.99603734706913,
2.99900342404273, 3.00194244739829, 3.00488435099674, 3.00770894228668,
3.01053618869243, 3.16820398996663, 3.20854156316688, 3.26499906051237,
3.32783396743193, 3.29260884488666, 3.47814406068718, 3.5075865501609,
3.69038091563598, 3.75894450266758, 3.80970904817611, 3.75232340078343,
3.69432373797752, 3.74402716954827, 3.81650404749639, 3.69081893620424,
3.70450449281968, 3.74449832332416, 3.80233958892455, 3.95449020757537,
4.08827852027806, 3.99034789660332, 4.07132402646909, 3.99911909485966,
3.92441155104859, 4.04774010845184, 4.05302240929337, 4.20473514411804,
4.16354135391111, 4.19852759190803, 4.1301587686014, 4.28167777318631,
4.28387427388395, 4.39932468556512, 4.40773619436392, 4.4631238073823,
4.52392047988646, 4.39067292607189, 4.39774190948286, 4.42687255189128,
4.52788935665288, 4.64603104574667, 4.79940117659781, 4.88550243370598,
4.95429519347499, 5.03119080917292, 4.92858973500145, 4.9851600879798,
5.20842546768007, 5.38548589145385, 5.29714238089044, 5.13541532685947,
5.20924719301373, 5.40357295030192, 5.49162417152709, 5.25779630592764,
5.22056059248906, 4.90946738678263, 4.91815714405724, 4.9233212090585,
4.92863839596428, 4.93573563525447, 4.94338602548911, 4.95010903048378,
4.95718768639737, 4.96184744282258, 4.96462607739057, 4.96542041756295,
4.96556938017547, 4.96611559280729, 4.9673571217055, 4.9682512459874,
4.96889711864938, 4.96964245321718, 4.97038789958516, 4.9711334577701,
5.14846373047568, 5.34266893085295, 5.24715269570716, 5.55802550431702,
5.66647925598276, 5.46645253824657, 5.63175806300315, 5.97226541900844,
6.06973876291208, 5.58152539525601, 5.29016976962365, 5.2908574916937,
5.04867378086891, 5.04933010846042, 5.24366872567485, 5.2399614518858,
5.59049391317115, 5.72551552216206), .Dim = c(194L, 2L), .Dimnames = list(
NULL, c("ind.passive", "ind.active")), .Tsp = c(1995, 2011.08333333333,
12), class = c("mts", "ts", "matrix"))
The date data set
structure(c(1995.1, 1995.2, 1995.3, 1995.4, 1995.5, 1995.6, 1995.7,
1995.8, 1995.9, 1995.1, 1995.11, 1995.12, 1996.1, 1996.2, 1996.3,
1996.4, 1996.5, 1996.6, 1996.7, 1996.8, 1996.9, 1996.1, 1996.11,
1996.12, 1997.1, 1997.2, 1997.3, 1997.4, 1997.5, 1997.6, 1997.7,
1997.8, 1997.9, 1997.1, 1997.11, 1997.12, 1998.1, 1998.2, 1998.3,
1998.4, 1998.5, 1998.6, 1998.7, 1998.8, 1998.9, 1998.1, 1998.11,
1998.12, 1999.1, 1999.2, 1999.3, 1999.4, 1999.5, 1999.6, 1999.7,
1999.8, 1999.9, 1999.1, 1999.11, 1999.12, 2000.1, 2000.2, 2000.3,
2000.4, 2000.5, 2000.6, 2000.7, 2000.8, 2000.9, 2000.1, 2000.11,
2000.12, 2001.1, 2001.2, 2001.3, 2001.4, 2001.5, 2001.6, 2001.7,
2001.8, 2001.9, 2001.1, 2001.11, 2001.12, 2002.1, 2002.2, 2002.3,
2002.4, 2002.5, 2002.6, 2002.7, 2002.8, 2002.9, 2002.1, 2002.11,
2002.12, 2003.1, 2003.2, 2003.3, 2003.4, 2003.5, 2003.6, 2003.7,
2003.8, 2003.9, 2003.1, 2003.11, 2003.12, 2004.1, 2004.2, 2004.3,
2004.4, 2004.5, 2004.6, 2004.7, 2004.8, 2004.9, 2004.1, 2004.11,
2004.12, 2005.1, 2005.2, 2005.3, 2005.4, 2005.5, 2005.6, 2005.7,
2005.8, 2005.9, 2005.1, 2005.11, 2005.12, 2006.1, 2006.2, 2006.3,
2006.4, 2006.5, 2006.6, 2006.7, 2006.8, 2006.9, 2006.1, 2006.11,
2006.12, 2007.1, 2007.2, 2007.3, 2007.4, 2007.5, 2007.6, 2007.7,
2007.8, 2007.9, 2007.1, 2007.11, 2007.12, 2008.1, 2008.2, 2008.3,
2008.4, 2008.5, 2008.6, 2008.7, 2008.8, 2008.9, 2008.1, 2008.11,
2008.12, 2009.1, 2009.2, 2009.3, 2009.4, 2009.5, 2009.6, 2009.7,
2009.8, 2009.9, 2009.1, 2009.11, 2009.12, 2010.1, 2010.2, 2010.3,
2010.4, 2010.5, 2010.6, 2010.7, 2010.8, 2010.9, 2010.1, 2010.11,
2010.12, 2011.1, 2011.2), .Tsp = c(1995, 2011.08333333333, 12
), class = "ts")
The spikes are in your data, specifically in the crummy way the dates are stored. January, February, March 1995 are coded as 1995.10, 1995.20, 1995.30, but then October, November, and December are 1995.10, 1995.11, 1995.12. When you pass your time series to ggplot you maybe saw a warning like:
Don't know how to automatically pick scale for object of type ts. Defaulting to continuous
So ggplot just converted to numerics, giving October the same x value as January and inserting Nov and Dec before February, causing your spikes. Since your samples (as far as I checked) are spaced every month, you could add a new column to your data like this:
ind.df <- as.data.frame(ind.ts)
ind.df$date <- seq(as.Date('1995-01-01'), as.Date('2011-02-01'), by = "month")
Then, ggplot works best with long-format data, so we can melt it
library(reshape2)
ind.melt <- melt(ind.df, id.vars = "date")
ggplot(ind.melt, aes(x = date, y = value, color = variable) +
geom_line(size = 1)
And the spikes are gone.
One other note, in ggplot don't put anything inside aes() that isn't mapping to a data column. In your post, inside aes() you have size = "1". You don't need the quotes around 1, and since it applies to the whole layer you should put it outside of aes().
The following example illustrates that for a very simple example, the plots from the basic R plotting and ggplot2 are the same, i.e. basic plotting does not get rid of the spikes, nor does ggplot2 introduces spikes. You need to make your example more complete, i.e. provide us with a sample of your data that reproduces the issue you see.
x = 1:100
y = runif(100)
y[50] = 5
plot(x, y)
library(ggplot2)
qplot(x, y, geom = 'line')

How to use Seq_along for multiple dates from a list in a loop

I have been fiddling around with a R project and have hit a roadblock. Ill explain what the goal is, It is to make a set of plots that show points plotted on a map based on their measurement time (water_level_date) and plot accordingly over a pre-selected time period.
The roadblock is that I have hit is that the loop creates other plots but doesn't apply the date restriction. so it produces the same plot 12 times. the loop I am currently using is
for (i in c(1:length(date)))
filename=paste(sprintf('%05d', i), ".png", sep="")
I just was a bit confused about what I should be using for the loop as I am using for() for dates and I think that its wrong, I think I have to use seq_along but I'm unsure how to get it to loop for a sequence say 01/01/1985 to 01/01/1986.
The dates are retrieved from a data frame but the issue is that it ignores the dates completely. Any help would be well appreciated. Yes, and I know I don't have a repeatable example just wondering how to properly use seq_along for a list of dates which loops between a start and end date.
DATA
structure(list(neg_decimal_lat = c(-35.9580624, -36.0270162,
-35.9505656, -35.9492215, -35.97803, -35.9766841, -35.9855039,
-35.98203, -35.984858, -36.0272577, -36.0048864, -35.9731485,
-35.9701733, -36.0034897, -36.0036909), decimal_long = c(140.3021648,
140.360413, 140.2858737, 140.2650201, 140.287947, 140.2547256,
140.2625761, 140.268055, 140.277901, 140.2702671, 140.2628329,
140.2857832, 140.2663454, 140.2683559, 140.2898351), max_drill_depth = c(67.5,
27.43, 38.4, 21.3, 18, 22, 67.1, 34, 34, 10.67, 40, 20, 16, 24,
40), water_level_date = structure(c(120L, 120L, 982L, 1320L,
1294L, 762L, 1320L, 592L, 729L, 817L, 90L, 1320L, 1320L, 202L,
631L), .Label = c("", "1/02/1972", "1/02/1985", "1/02/1996",
"1/02/2006", "1/03/2007", "1/03/2013", "1/04/1976", "1/04/1978",
"1/04/1985", "1/04/1992", "1/04/1998", "1/04/1999", "1/04/2011",
"1/05/2013", "1/06/1979", "1/06/1982", "1/06/1983", "1/06/1995",
"1/06/2000", "1/06/2006", "1/07/1985", "1/07/1986", "1/07/2003",
"1/07/2004", "1/07/2008", "1/07/2013", "1/08/1972", "1/08/1980",
"1/08/1983", "1/08/1993", "1/09/1978", "1/09/1998", "1/10/1974",
"1/10/1975", "1/10/1992", "1/10/1995", "1/10/2008", "1/10/2010",
"1/11/1974", "1/11/1991", "1/11/1999", "1/12/1971", "1/12/1976",
"1/12/1983", "1/12/2000", "1/12/2003", "1/12/2009", "10/01/1980",
"10/01/1997", "10/01/2012", "10/02/1970", "10/02/1980", "10/02/1982",
"10/03/2011", "10/04/1986", "10/04/1989", "10/04/1991", "10/04/1996",
"10/04/2002", "10/04/2013", "10/05/1969", "10/05/1988", "10/05/1989",
"10/06/1998", "10/07/1979", "10/07/1987", "10/07/2002", "10/07/2013",
"10/08/1976", "10/08/2012", "10/09/1975", "10/09/1979", "10/09/1981",
"10/09/1988", "10/09/2012", "10/10/1985", "10/10/2005", "10/10/2012",
"10/11/1969", "10/11/1970", "10/11/1981", "10/11/1988", "10/11/2000",
"10/11/2004", "10/12/1998", "10/12/2003", "10/12/2004", "10/12/2009",
"11/01/2008", "11/01/2012", "11/02/1974", "11/03/1970", "11/03/1977",
"11/03/1983", "11/03/1985", "11/03/1991", "11/03/2003", "11/04/1973",
"11/04/1975", "11/04/1991", "11/04/1994", "11/04/2013", "11/05/1973",
"11/05/1982", "11/05/1988", "11/05/2004", "11/05/2011", "11/06/1979",
"11/06/1981", "11/06/1999", "11/06/2010", "11/06/2013", "11/07/2005",
"11/07/2013", "11/08/1978", "11/08/1982", "11/08/2004", "11/09/1974",
"11/09/1978", "11/09/1981", "11/09/1996", "11/09/1997", "11/09/2006",
"11/10/1978", "11/10/1984", "11/10/1985", "11/10/1989", "11/10/2006",
"11/10/2008", "11/10/2011", "11/10/2012", "11/11/1981", "11/11/1991",
"11/12/1967", "11/12/1971", "11/12/1985", "11/12/2001", "11/12/2009",
"12/01/1979", "12/02/1975", "12/02/1979", "12/03/1971", "12/03/1981",
"12/03/1997", "12/03/1998", "12/03/2001", "12/03/2003", "12/04/1973",
"12/04/1977", "12/04/1983", "12/04/2013", "12/05/1982", "12/06/1977",
"12/06/1987", "12/06/2001", "12/06/2007", "12/06/2013", "12/07/1974",
"12/07/1983", "12/07/2010", "12/07/2013", "12/08/1991", "12/08/2002",
"12/08/2013", "12/09/1975", "12/09/1978", "12/09/1980", "12/09/1988",
"12/09/1997", "12/10/1982", "12/10/1999", "12/10/2000", "12/10/2004",
"12/10/2006", "12/11/1969", "12/11/1979", "12/11/1997", "12/12/1979",
"12/12/1988", "12/12/2003", "13/01/1989", "13/01/2013", "13/02/1981",
"13/02/1985", "13/02/1990", "13/03/1974", "13/03/1998", "13/03/2001",
"13/03/2003", "13/03/2013", "13/04/1988", "13/04/2004", "13/05/1981",
"13/05/1983", "13/06/2013", "13/07/1971", "13/07/1987", "13/07/1999",
"13/07/2010", "13/08/1974", "13/08/1998", "13/08/2013", "13/09/1974",
"13/09/1978", "13/09/1979", "13/09/1983", "13/09/1984", "13/09/1989",
"13/09/1990", "13/09/1993", "13/09/1994", "13/09/2000", "13/09/2010",
"13/10/1998", "13/10/2004", "13/10/2006", "13/10/2008", "13/10/2011",
"13/11/1996", "13/12/1996", "13/12/1999", "13/12/2001", "13/12/2004",
"14/01/1977", "14/02/1984", "14/02/1990", "14/03/1994", "14/03/2000",
"14/03/2001", "14/03/2002", "14/03/2008", "14/03/2012", "14/03/2013",
"14/04/1980", "14/04/1989", "14/05/1982", "14/05/1983", "14/05/1985",
"14/05/2002", "14/05/2010", "14/06/1967", "14/06/1968", "14/06/1989",
"14/06/1996", "14/06/2002", "14/06/2013", "14/07/1983", "14/08/1973",
"14/08/2013", "14/09/1973", "14/09/1978", "14/09/1993", "14/09/1994",
"14/09/1998", "14/09/2000", "14/09/2009", "14/10/1986", "14/10/1988",
"14/10/1997", "14/11/1962", "14/11/1984", "14/11/1986", "14/11/1996",
"14/11/2000", "14/12/1987", "14/12/1998", "14/12/1999", "14/12/2000",
"14/12/2001", "15/02/1968", "15/03/1977", "15/03/1979", "15/03/1989",
"15/03/1991", "15/03/1994", "15/03/1995", "15/03/1996", "15/03/1999",
"15/03/2000", "15/03/2001", "15/03/2003", "15/03/2010", "15/04/1999",
"15/04/2009", "15/05/1991", "15/07/1980", "15/07/1982", "15/07/2010",
"15/07/2013", "15/08/2013", "15/09/1971", "15/09/1975", "15/09/1978",
"15/09/1989", "15/09/1992", "15/09/1994", "15/09/1995", "15/09/1997",
"15/09/2000", "15/09/2003", "15/09/2009", "15/10/1993", "15/10/1996",
"15/10/2002", "15/10/2006", "15/11/1994", "15/11/1996", "15/12/1977",
"15/12/1983", "15/12/1989", "15/12/1994", "15/12/2000", "15/12/2008",
"16/01/1979", "16/01/2012", "16/02/1971", "16/02/1978", "16/02/2008",
"16/03/1977", "16/03/1979", "16/03/1989", "16/03/1991", "16/03/1993",
"16/03/1998", "16/03/2000", "16/03/2003", "16/03/2007", "16/03/2010",
"16/04/2008", "16/04/2013", "16/05/1979", "16/05/1996", "16/06/1989",
"16/06/1992", "16/06/1997", "16/06/2008", "16/07/1974", "16/07/1977",
"16/07/1982", "16/07/1996", "16/07/2008", "16/07/2013", "16/08/1988",
"16/08/1995", "16/08/2013", "16/09/1969", "16/09/1976", "16/09/1979",
"16/09/1993", "16/09/2005", "16/10/1970", "16/10/1986", "16/10/1995",
"16/10/2001", "16/10/2006", "16/10/2008", "16/11/1981", "16/12/1971",
"16/12/1979", "16/12/1980", "16/12/2003", "17/01/1974", "17/01/1980",
"17/01/1985", "17/01/2008", "17/02/1979", "17/03/1972", "17/03/1977",
"17/03/1998", "17/03/1999", "17/03/2002", "17/03/2010", "17/04/1998",
"17/04/2007", "17/04/2013", "17/05/1977", "17/05/2002", "17/05/2012",
"17/06/1977", "17/06/1986", "17/06/2002", "17/06/2013", "17/07/1996",
"17/07/2008", "17/07/2013", "17/08/1989", "17/08/1990", "17/08/1994",
"17/09/1969", "17/09/1974", "17/09/1975", "17/09/1984", "17/09/1992",
"17/09/1993", "17/09/1996", "17/09/1998", "17/09/2008", "17/10/1991",
"17/10/1994", "17/11/1983", "17/11/1997", "17/12/1985", "17/12/1986",
"17/12/1991", "17/12/1997", "17/12/1999", "17/12/2009", "17/12/2012",
"18/01/1972", "18/01/1977", "18/01/1984", "18/01/1995", "18/01/2005",
"18/01/2007", "18/02/1975", "18/02/2008", "18/03/1973", "18/03/1977",
"18/03/1996", "18/03/1998", "18/03/2009", "18/03/2010", "18/03/2013",
"18/04/1996", "18/04/2000", "18/04/2013", "18/05/1990", "18/06/2002",
"18/06/2008", "18/06/2010", "18/06/2013", "18/07/1973", "18/07/2000",
"18/08/1979", "18/08/1983", "18/09/1978", "18/09/1991", "18/09/1992",
"18/09/1996", "18/09/2000", "18/09/2012", "18/10/1991", "18/10/2001",
"18/10/2005", "18/10/2012", "18/12/1981", "18/12/1992", "18/12/2008",
"19/01/1957", "19/01/1971", "19/01/1974", "19/01/1984", "19/02/1975",
"19/02/1985", "19/03/1972", "19/03/1984", "19/03/1999", "19/03/2010",
"19/03/2013", "19/04/1971", "19/04/1996", "19/04/2000", "19/04/2006",
"19/04/2013", "19/05/1999", "19/05/2009", "19/06/1985", "19/06/1989",
"19/06/2002", "19/06/2006", "19/06/2008", "19/06/2013", "19/07/1980",
"19/07/1982", "19/07/1985", "19/07/2013", "19/08/1969", "19/08/2013",
"19/09/1973", "19/09/1975", "19/09/1977", "19/09/1978", "19/09/1979",
"19/09/1988", "19/09/2001", "19/09/2002", "19/09/2003", "19/11/1996",
"2/01/1975", "2/01/1986", "2/01/1996", "2/01/2007", "2/02/1973",
"2/02/1977", "2/02/1989", "2/03/1982", "2/03/1995", "2/04/1974",
"2/04/1976", "2/04/1980", "2/04/1984", "2/04/1985", "2/04/1996",
"2/04/2003", "2/04/2004", "2/04/2013", "2/05/1981", "2/05/2008",
"2/05/2011", "2/06/1982", "2/06/1992", "2/06/1997", "2/06/2009",
"2/06/2010", "2/07/1974", "2/07/1985", "2/07/1986", "2/07/1987",
"2/07/1999", "2/07/2008", "2/08/1971", "2/08/1993", "2/08/1996",
"2/08/2004", "2/09/1977", "2/09/1998", "2/09/2013", "2/10/1986",
"2/10/1987", "2/10/2008", "2/11/1971", "2/11/1981", "2/12/1939",
"2/12/1959", "2/12/1974", "2/12/1982", "2/12/1986", "2/12/1992",
"2/12/1998", "2/12/2011", "20/01/1983", "20/01/1984", "20/03/1974",
"20/03/1998", "20/03/1999", "20/03/2001", "20/03/2003", "20/03/2006",
"20/03/2009", "20/03/2013", "20/04/1993", "20/04/2012", "20/05/1982",
"20/05/1989", "20/06/1988", "20/06/1991", "20/06/2001", "20/06/2002",
"20/06/2005", "20/06/2007", "20/06/2008", "20/06/2013", "20/07/1973",
"20/07/1989", "20/08/1980", "20/08/1991", "20/09/1971", "20/09/1974",
"20/09/1978", "20/09/1988", "20/09/1993", "20/09/1994", "20/09/1996",
"20/09/2000", "20/09/2005", "20/09/2012", "20/10/1981", "20/10/1999",
"20/10/2000", "20/11/1995", "20/11/1996", "20/12/1983", "20/12/1991",
"20/12/2012", "21/02/2001", "21/03/1969", "21/03/1975", "21/03/1977",
"21/03/1979", "21/03/1984", "21/03/1987", "21/03/1988", "21/03/1995",
"21/03/2000", "21/03/2001", "21/03/2003", "21/03/2007", "21/03/2013",
"21/04/1980", "21/04/1981", "21/04/1990", "21/04/1999", "21/05/2012",
"21/06/2007", "21/06/2010", "21/06/2013", "21/07/1977", "21/08/1985",
"21/08/1992", "21/09/1973", "21/09/1978", "21/09/1989", "21/09/1992",
"21/09/2009", "21/10/1993", "21/11/1981", "21/11/1985", "21/11/1990",
"21/12/1953", "21/12/1981", "21/12/1990", "21/12/1995", "21/12/2000",
"21/12/2009", "21/12/2012", "22/02/1973", "22/02/1974", "22/02/1979",
"22/02/1983", "22/02/1999", "22/02/2000", "22/03/1977", "22/03/1983",
"22/03/1985", "22/03/1987", "22/03/1993", "22/03/2000", "22/03/2001",
"22/03/2004", "22/03/2011", "22/03/2012", "22/03/2013", "22/04/1969",
"22/04/1985", "22/04/1998", "22/04/2013", "22/05/1968", "22/05/1972",
"22/05/1978", "22/05/2002", "22/05/2012", "22/06/1972", "22/06/1978",
"22/06/1982", "22/06/2004", "22/06/2010", "22/07/1981", "22/07/1988",
"22/07/2010", "22/07/2013", "22/08/1973", "22/08/2001", "22/08/2013",
"22/09/1983", "22/09/1992", "22/09/1996", "22/09/1998", "22/09/1999",
"22/09/2004", "22/10/1974", "22/10/1976", "22/10/1985", "22/10/1986",
"22/10/1991", "22/10/2012", "22/11/1967", "22/11/1983", "22/11/1984",
"22/11/1995", "22/11/2012", "22/12/1982", "22/12/1983", "22/12/2011",
"23/01/1976", "23/02/1978", "23/02/1982", "23/02/2000", "23/03/1977",
"23/03/1984", "23/03/1994", "23/03/1998", "23/03/1999", "23/03/2000",
"23/03/2001", "23/03/2006", "23/03/2009", "23/03/2011", "23/04/1981",
"23/04/2007", "23/04/2013", "23/06/1998", "23/06/2005", "23/07/1979",
"23/07/2002", "23/07/2013", "23/08/1974", "23/08/1982", "23/08/1985",
"23/08/2005", "23/09/1974", "23/09/1975", "23/09/1985", "23/09/1986",
"23/09/1992", "23/09/1994", "23/09/1996", "23/09/2003", "23/09/2009",
"23/09/2010", "23/10/1979", "23/10/1986", "23/10/1989", "23/10/1991",
"23/11/1973", "23/12/1977", "23/12/1982", "24/01/1967", "24/02/2000",
"24/03/1988", "24/03/1993", "24/03/1997", "24/03/2000", "24/03/2005",
"24/04/1978", "24/04/2012", "24/04/2013", "24/05/1977", "24/05/1982",
"24/05/2002", "24/05/2006", "24/06/1974", "24/06/1981", "24/06/1982",
"24/06/1983", "24/06/1992", "24/06/2009", "24/06/2013", "24/07/1972",
"24/07/1992", "24/07/2008", "24/07/2013", "24/08/1978", "24/08/1983",
"24/09/1984", "24/09/1986", "24/09/1992", "24/09/1996", "24/09/1997",
"24/09/2008", "24/09/2009", "24/09/2011", "24/10/1973", "24/10/1979",
"24/10/1984", "24/10/1985", "24/11/1986", "24/11/1994", "25/01/1977",
"25/02/1994", "25/02/2013", "25/03/1969", "25/03/1975", "25/03/1977",
"25/03/1986", "25/03/1993", "25/03/2010", "25/03/2013", "25/04/2013",
"25/05/2002", "25/05/2007", "25/06/1984", "25/06/1985", "25/06/1999",
"25/06/2002", "25/06/2008", "25/06/2013", "25/07/1972", "25/07/1977",
"25/07/1980", "25/07/1987", "25/08/1969", "25/08/1980", "25/09/1974",
"25/09/1980", "25/09/1985", "25/09/1992", "25/09/1995", "25/09/1996",
"25/10/1976", "25/10/1980", "25/10/1984", "25/10/1991", "25/10/2005",
"25/10/2007", "25/10/2010", "25/11/1971", "25/11/1985", "26/02/1994",
"26/02/2013", "26/03/1977", "26/03/1978", "26/03/1980", "26/03/1985",
"26/03/1992", "26/03/2001", "26/04/2011", "26/05/2010", "26/06/1969",
"26/06/1985", "26/06/2001", "26/06/2002", "26/06/2003", "26/06/2013",
"26/07/1990", "26/07/1999", "26/07/2002", "26/07/2013", "26/08/1977",
"26/08/1980", "26/08/1996", "26/08/2013", "26/09/1974", "26/09/1978",
"26/09/1989", "26/09/1995", "26/09/2001", "26/09/2005", "26/09/2011",
"26/10/1978", "26/10/1985", "26/10/1993", "26/10/2005", "26/10/2010",
"26/11/1971", "26/11/1984", "27/01/1988", "27/02/1984", "27/02/2003",
"27/02/2013", "27/03/1984", "27/03/1992", "27/03/1995", "27/03/1998",
"27/03/2001", "27/03/2003", "27/03/2012", "27/03/2013", "27/04/1971",
"27/05/1976", "27/06/1978", "27/06/1982", "27/06/1985", "27/06/1986",
"27/06/2006", "27/06/2013", "27/07/1971", "27/07/1983", "27/07/1995",
"27/08/2012", "27/09/1973", "27/09/1985", "27/09/1988", "27/09/1993",
"27/09/1995", "27/09/1999", "27/09/2002", "27/09/2005", "27/09/2011",
"27/10/2006", "27/11/1997", "28/01/1976", "28/01/1983", "28/02/2002",
"28/02/2013", "28/03/1977", "28/03/1982", "28/03/1983", "28/03/1990",
"28/03/2000", "28/03/2003", "28/03/2006", "28/03/2012", "28/04/1976",
"28/04/1977", "28/04/1978", "28/04/1983", "28/04/1987", "28/04/2002",
"28/05/1980", "28/06/1977", "28/06/1985", "28/06/2006", "28/06/2013",
"28/07/1982", "28/08/1978", "28/08/1991", "28/08/2012", "28/09/1992",
"28/09/2000", "28/09/2006", "28/09/2011", "28/10/1985", "28/10/1986",
"28/10/1991", "28/10/1993", "28/11/1976", "28/11/1979", "28/11/2001",
"29/01/1953", "29/01/1969", "29/01/1998", "29/03/1974", "29/03/1977",
"29/03/1979", "29/03/1993", "29/03/1999", "29/03/2011", "29/03/2012",
"29/04/1977", "29/04/1978", "29/04/2002", "29/04/2009", "29/05/1978",
"29/05/2013", "29/06/1984", "29/06/2005", "29/07/1975", "29/07/1980",
"29/07/1996", "29/07/2013", "29/08/1978", "29/08/1985", "29/09/1978",
"29/09/1983", "29/09/1992", "29/09/1999", "29/09/2009", "29/10/1976",
"29/10/1985", "29/10/1986", "29/10/1987", "29/10/1995", "29/10/2002",
"29/10/2004", "29/11/1995", "3/01/1975", "3/01/2007", "3/02/1976",
"3/02/1989", "3/02/1992", "3/02/1997", "3/02/1999", "3/03/1969",
"3/03/1982", "3/03/2003", "3/03/2004", "3/03/2008", "3/03/2010",
"3/04/1992", "3/04/1996", "3/04/1997", "3/04/2002", "3/04/2003",
"3/04/2012", "3/04/2013", "3/05/1973", "3/05/1990", "3/06/1976",
"3/06/1982", "3/06/1993", "3/07/1986", "3/07/1996", "3/07/2002",
"3/08/1975", "3/09/1975", "3/09/1985", "3/09/1992", "3/09/1996",
"3/09/2007", "3/10/1973", "3/10/1975", "3/10/1979", "3/10/1980",
"3/10/1988", "3/10/1989", "3/10/1990", "3/10/2006", "3/11/1968",
"3/11/1970", "3/11/1986", "3/12/1981", "3/12/1982", "3/12/1993",
"3/12/1997", "3/12/2002", "30/01/1999", "30/01/2006", "30/01/2007",
"30/03/1977", "30/03/1992", "30/03/2001", "30/03/2011", "30/03/2012",
"30/04/1956", "30/04/1980", "30/04/1998", "30/04/2001", "30/04/2004",
"30/04/2010", "30/04/2011", "30/05/1995", "30/05/2000", "30/06/1976",
"30/06/2004", "30/06/2009", "30/07/1980", "30/07/1982", "30/07/1984",
"30/07/2001", "30/07/2013", "30/08/1976", "30/08/1978", "30/08/1982",
"30/08/1985", "30/08/1989", "30/08/2002", "30/09/1971", "30/09/1974",
"30/09/1980", "30/09/1992", "30/09/1998", "30/09/2011", "30/10/1978",
"30/10/1986", "30/10/1991", "30/10/1995", "30/10/2001", "30/10/2003",
"30/10/2006", "30/11/1978", "30/11/1995", "30/11/2010", "30/11/2012",
"31/01/1980", "31/01/1991", "31/01/1997", "31/01/2006", "31/01/2013",
"31/03/1977", "31/03/1992", "31/03/1995", "31/03/1998", "31/07/1986",
"31/07/2013", "31/08/1978", "31/08/1979", "31/08/1982", "31/08/1983",
"31/08/1993", "31/08/1999", "31/08/2012", "31/10/1984", "31/10/1986",
"31/10/2006", "31/12/1982", "4/01/1982", "4/01/1990", "4/02/1970",
"4/02/1980", "4/03/1971", "4/03/1994", "4/03/1996", "4/03/1998",
"4/03/1999", "4/03/2013", "4/04/1974", "4/04/1991", "4/04/2003",
"4/04/2005", "4/05/1981", "4/05/1982", "4/05/1985", "4/05/2004",
"4/05/2010", "4/06/1993", "4/06/1997", "4/06/1998", "4/06/1999",
"4/06/2002", "4/06/2003", "4/06/2013", "4/07/1985", "4/07/1986",
"4/07/2002", "4/07/2005", "4/08/1977", "4/08/1982", "4/08/1983",
"4/08/1986", "4/09/1978", "4/10/1968", "4/10/1971", "4/10/1974",
"4/10/1977", "4/10/1982", "4/10/1996", "4/10/2001", "4/10/2012",
"4/11/1977", "4/12/1976", "4/12/2000", "4/12/2006", "4/12/2007",
"4/12/2008", "5/01/1983", "5/02/1965", "5/02/2009", "5/03/1974",
"5/03/1981", "5/03/1987", "5/03/2002", "5/03/2010", "5/03/2013",
"5/04/2001", "5/05/1981", "5/05/2010", "5/06/1969", "5/06/1985",
"5/06/2013", "5/07/1975", "5/07/2007", "5/07/2012", "5/07/2013",
"5/08/1986", "5/08/2002", "5/08/2004", "5/09/1977", "5/09/1978",
"5/09/1991", "5/10/1993", "5/10/2005", "5/10/2011", "5/11/1969",
"5/11/1979", "5/11/1981", "5/12/1972", "5/12/1973", "5/12/2006",
"5/12/2012", "6/01/1994", "6/01/2012", "6/02/1970", "6/02/2006",
"6/03/1989", "6/03/2000", "6/03/2001", "6/03/2003", "6/03/2012",
"6/04/1978", "6/04/1994", "6/04/1998", "6/04/2000", "6/04/2009",
"6/05/1969", "6/05/2003", "6/06/1984", "6/06/2013", "6/07/1977",
"6/07/2007", "6/08/1967", "6/08/1973", "6/08/1982", "6/08/2013",
"6/09/1973", "6/09/1977", "6/09/1978", "6/09/1988", "6/09/1999",
"6/09/2005", "6/09/2011", "6/10/1983", "6/10/1985", "6/10/1986",
"6/10/1987", "6/10/1988", "6/10/1993", "6/10/2004", "6/10/2011",
"6/11/1976", "6/11/1981", "6/12/1977", "7/01/1986", "7/02/1995",
"7/02/2006", "7/03/1974", "7/03/1978", "7/03/1979", "7/03/1983",
"7/03/1985", "7/03/1989", "7/03/1991", "7/03/1997", "7/03/2000",
"7/03/2005", "7/03/2011", "7/04/1976", "7/04/1979", "7/04/1986",
"7/04/1987", "7/04/1998", "7/04/1999", "7/04/2005", "7/04/2006",
"7/04/2008", "7/05/1975", "7/05/2010", "7/05/2012", "7/06/1971",
"7/06/1995", "7/07/1977", "7/07/1982", "7/07/1986", "7/07/2010",
"7/08/1980", "7/09/1978", "7/09/1989", "7/09/1999", "7/10/1971",
"7/10/1977", "7/10/1987", "7/10/1993", "7/10/2003", "7/10/2008",
"7/11/1970", "7/11/1980", "7/11/1984", "7/11/2000", "7/11/2001",
"7/11/2002", "7/11/2006", "7/12/1976", "7/12/1978", "7/12/2000",
"7/12/2005", "7/12/2012", "8/02/1968", "8/02/1990", "8/03/1974",
"8/03/1978", "8/03/1979", "8/03/1988", "8/03/1989", "8/03/1993",
"8/03/1994", "8/03/1995", "8/03/2001", "8/03/2003", "8/03/2013",
"8/04/1981", "8/04/1982", "8/04/2008", "8/04/2009", "8/04/2010",
"8/04/2013", "8/05/1981", "8/05/1986", "8/06/1979", "8/06/2001",
"8/07/1975", "8/07/1982", "8/07/2010", "8/07/2013", "8/08/1990",
"8/08/2009", "8/08/2013", "8/09/1978", "8/09/1988", "8/09/1997",
"8/09/2000", "8/09/2006", "8/10/1985", "8/10/1986", "8/10/2002",
"8/10/2003", "8/10/2009", "8/10/2012", "8/11/1970", "8/11/1996",
"8/11/2000", "8/11/2002", "8/12/1977", "8/12/1987", "8/12/1988",
"8/12/1995", "9/01/1971", "9/01/1985", "9/01/2012", "9/02/1970",
"9/02/1982", "9/02/1990", "9/02/1996", "9/03/1982", "9/03/1988",
"9/03/2009", "9/03/2010", "9/04/1986", "9/04/1991", "9/04/1996",
"9/04/2013", "9/05/2012", "9/07/2008", "9/07/2013", "9/08/1991",
"9/08/2002", "9/08/2013", "9/09/1975", "9/09/1982", "9/09/1993",
"9/09/1997", "9/09/1998", "9/09/2008", "9/10/1991", "9/10/1996",
"9/10/2003", "9/10/2012", "9/11/1976", "9/11/1992", "9/11/1999",
"9/12/1988", "9/12/1997"), class = "factor")), .Names = c("neg_decimal_lat",
"decimal_long", "max_drill_depth", "water_level_date"), row.names = c(NA,
15L), class = "data.frame")
The code is as follows
require(ggplot2)
require('ggmap')
plotdata <- plotdata[1:15, c("neg_decimal_lat", "decimal_long",
"max_drill_depth", "water_level_date")]
date <- factor(plotdata$water_level_date,
levels=plotdata$water_level_date[!duplicated(plotdata$water_level_date)])
colormap <- c("darkblue","blue","lightblue", "green",
"yellow", "orange","darkorange", "red", "darkred")
depth <- c(1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50,60,70,80,90,100,110, #legendrange
120,130,140,150,160,170,180,190, 200, 300, 400,500,600, 700,
800,900, 1000,1100,1200,1300,1400, 1500, 2400)
# static map drawn based on min max of latlong
map.plot<- get_map(location = c(min(plotdata$decimal_long),
min(plotdata$neg_decimal_lat),
max(plotdata$decimal_long),
max(plotdata$neg_decimal_lat)),
source = "osm", zoom=6)
theme_set(theme_bw(base_size = 8))
static.map <- ggmap(map.plot) %+% plotdata +
aes(x = decimal_long,
y = neg_decimal_lat,
z = max_drill_depth) +
stat_summary2d(fun = median, binwidth = c(.01, .01),alpha = 1) +
scale_fill_gradientn(name = "Drill Depth",colours = colormap, breaks=depth,
labels = format(depth), space = "Lab") +
labs(x = "Longitude",y = "Latitude" )+ coord_map()
Dates <- seq(as.Date("1985/1/1"), as.Date("1995/1/1"), "years")
#current loop for date
for (i in seq_along(Dates)){
filename=paste(sprintf('%05d', i), ".png", sep="")
print(static.map)
ggsave(filename=filename,
plot = static.map,
scale = 4,
width = 5, height = 3,
dpi = 300)
}
The overall aim is to get it for example to draw all points that were recorded in 1985-1986 and exclude all others, but also showing each month and the points are drawn at their specific month. These would be made into 12 images. Also watch out as the loop is bugged and keeps printing more of the same map so don't forget to stop it.
A reproducible example would help. It is not clear what the problem is.
This seems to work:
Dates <- seq(as.Date("1985/1/1"), as.Date("1995/1/1"), "years")
for (i in seq_along(Dates)) {
filename=paste(sprintf('%05d', i), ".png", sep="")
print(filename)
}

r lattice wireframe different colours under specific conditions

I plot data in a 3D form using wireframe from the lattice package to show the volatility term structure. Here is the data:
library(lattice)
con <- textConnection (" X1M X2M X3M X6M X9M X12M X18M X24M VSTOXX Euro.Stoxx.50
2006-04-14 14.850 15.076 15.462 15.950 16.396 16.700 17.146 17.968 15.068 3793.830
2006-04-21 16.468 15.028 15.476 15.900 16.342 16.858 17.402 18.030 14.930 3824.030
2006-04-28 14.576 15.070 14.560 15.552 15.996 16.262 16.850 17.630 14.810 3865.136
2006-05-05 14.806 14.990 14.770 15.584 16.132 16.378 16.868 17.668 14.906 3848.302
2006-05-12 15.944 14.968 14.734 15.260 15.840 15.582 16.496 17.338 15.028 3844.066
2006-05-19 27.708 18.316 17.466 17.250 17.412 17.478 17.796 17.646 19.204 3655.658
2006-05-26 23.756 20.862 19.650 19.922 19.348 19.256 19.362 19.330 22.732 3613.942
2006-06-02 23.172 21.504 20.720 21.046 20.332 20.188 20.054 20.404 22.078 3638.574
2006-06-09 24.972 22.898 22.366 22.416 21.448 21.204 20.788 21.146 23.168 3535.830
2006-06-16 28.138 24.660 23.888 23.330 22.604 22.010 21.850 22.248 25.150 3451.960
2006-06-23 21.114 20.606 20.256 19.898 19.820 19.954 20.350 21.168 21.194 3525.386
2006-06-30 20.722 20.188 19.884 19.566 19.360 19.438 19.808 20.088 20.508 3555.864
2006-07-07 18.348 18.380 18.574 18.702 18.552 19.038 19.374 19.806 18.370 3653.206
2006-07-14 21.944 19.834 19.922 19.660 19.606 19.740 20.096 20.332 19.960 3597.120
2006-07-21 24.876 21.276 21.160 20.654 20.536 20.746 21.008 21.330 21.224 3544.618
2006-07-28 18.506 18.696 18.642 19.106 19.332 19.806 20.248 20.644 18.606 3659.466
2006-08-04 18.718 18.934 18.914 19.282 19.292 19.714 20.080 20.470 18.878 3682.964
2006-08-11 20.586 19.798 19.534 19.666 19.504 19.736 20.154 20.570 19.878 3676.808
2006-08-18 19.258 17.696 18.112 18.452 18.628 19.080 19.698 20.068 17.566 3773.618
")
Dat<- read.table(con, header = TRUE)
I would like to show two following things in a 3D plot (separately) :
1.) I can simply control levels for which I have different colours by
data2<-Dat[,c(8,7,6,5,4,3,2,1)]
wireframe(as.matrix(data2),
aspect = c(61/87, 0.4), drape = TRUE,
scales = list(arrows = F, cex= 0.5, font = 1),
xlab='Date', ylab='Maturity', zlab='Value',
col.regions=c("#FF3030","#551A8B","#43CD80"),
at=c(0,18,25,30))
but how can I have different colours for the periods whith flat/steep/inverse term structure ?
2.) The data set actually represents 9 weeks before and after the 2006-06-16 (or any other date,not necessarilly 9 weeks time span ) and I would like to highlight this specific date either by different colour in a 3D plot or some arrow / text/...
Thanks,
Alexander

Resources