Dear friends, I have the following dataframe: dim(alajuela_df) [1] 126 12 dput(alajuela_df) structure(list(...1 = c(92.9925354, 76.0024254, 44.99547465, 28.00536465, 120.0068103, 31.9980405, 85.0071837, 40.1532933, 19.3120917, 113.12581575, 28.45843425, 114.400074, 143.0000925, 46.439634, 20.7845679, 50.82874575, 36.9818061, 44.6273556, 40.57804605, 30.38398005, 47.94042705, 36.38715225, 28.06199835, 28.4867511, 122.86681215, 56.4071652, 35.9057658, 52.669341, 24.94714485, 54.4249857, 61.164396, 47.88379335, 30.582198, 26.051502, 43.041612, 64.59073485, 51.6499344, 78.8202902886201, 35.2390173175627, 82.2394568898745, 47.760850180466, 54.3654763342294, 49.4878058854839, 32.8813266149642, 38.9301880693548, 51.9506275455197, 55.4404001992832, 50.7979761262545, 37.1198211413082, 36.9144309425627, 33.7829493281362, 32.8647492475806, 42.8926863444444, 63.9814428257048, 39.219040238172, 88.7557324417563, 42.0964144925627, 129.15973304991, 117.872998635484, 35.4004098300179, 83.4102757505377, 38.6443638074373, 100.491764259319, 40.219162961828, 35.901029409319, 85.2814714674731, 26.5821299974014, 33.0141992892473, 52.4006692386201, 62.7450310643369, 33.3732853655914, 36.4616827405018, 146.501706130466, 59.9869292767025, 132.659282967294, 29.9692075517921, 45.8436438112007, 29.3028312143369, 49.9042699517921, 27.4678688861111, 29.8483957580645, 26.1192323867384, 62.1371491517921, 53.92489050681, 64.5840869873656, 28.4476420455197, 52.9893180218638, 36.4730500781362, 40.8595060662186, 33.4571194806452, 35.6201445262545, 47.5373940344086, 62.5177012273297, 31.9702480361111, 29.6637272685484, 49.9578249978495, 26.1936613831541, 30.8051128442652, 153.165249601165, 36.7652008047491, 14.3854334390681, 55.9930862447133, 87.5882628859319, 88.414763059767, 58.6046644034946, 20.5301898890681, 39.0037205346774, 67.5971386298632, 25.1295804696237, 32.7864973072581, 59.5662701215054, 56.3503435331631, 25.2768483884409, 120.187620533964, 51.3699688189953, 42.6889983487868, 34.5183987020052, 32.9513272936733, 20.6141437461215, 43.4197954932283, 107.258904254306, 23.7548470509806, 48.4457090643702, 72.3249287581108, 32.7272590911596, 48.6115621286089), ...2 = c(34.9996266, 22.00219245, 22.9932822, 19.00060635, 35.99071635, 23.9560551, 44.99547465, 22.00219245, 17.35822905, 38.9639856, 16.4804067, 93.87035775, 81.2693595, 65.4119235, 14.6114946, 33.32893245, 23.3330844, 66.68618175, 29.1097218, 18.77407155, 28.1469489, 20.64298365, 15.31941585, 25.79665035, 39.5869563, 35.9057658, 28.11863205, 27.09922545, 18.03783345, 52.3295388, 47.99706075, 21.88892505, 18.8590221, 17.64139755, 29.2796229, 27.750513, 26.9576412, 36.8932410314484, 19.1194611744253, 37.5166237491071, 37.9625421619439, 23.444984650496, 37.4408609345785, 43.1033210084325, 28.1252430606151, 38.4216392645833, 41.0532302780651, 34.4822260610119, 27.8096188059524, 25.9720387760913, 19.5989670673372, 21.1366557174603, 34.0091174203373, 111.149568174301, 24.5438738482759, 62.923693488747, 36.056976280754, 36.934798630754, 47.0895472967433, 23.0987961767857, 45.1991799260913, 23.0274422095238, 26.8716961246169, 21.5009916962302, 25.315076619246, 41.2098751296627, 15.6537752838123, 20.1723471152778, 31.7437694203373, 34.6486999232143, 27.6318028338123, 23.9637897951389, 50.6646878095238, 33.3208231933532, 38.0673028746602, 19.9469359998016, 27.0503264451389, 19.8385753555556, 29.0062549955939, 17.231889453373, 25.3320442555556, 17.651735447619, 37.12988188841, 37.7982565469246, 33.1890524548611, 15.4283008803571, 33.5040593288314, 24.9726150325397, 29.0612348127976, 30.2629592267857, 32.8065534719349, 43.3676303365079, 39.19334780424, 23.9252474159722, 15.8641806903257, 27.51501019685, 21.5861832758362, 18.5136698379577, 54.9166790494253, 29.2865335598214, 12.8130786005824, 46.2078437446569, 37.9351942968391, 31.8758398080357, 25.4830299994048, 17.4062173291544, 19.1528843310516, 37.2160194109127, 25.3577400835684, 21.3381885368056, 37.5842732179795, 62.4856267757438, 19.2393143990079, 49.4806272500855, 29.5274325254668, 18.7819282827049, 19.5089694997422, 25.524181172185, 15.9275217745507, 25.461470312583, 37.4026236465872, 14.6120197959536, 26.5773978462589, 27.6541154512847, 22.5193597452548, 27.9919830179818), ...3 = c(24.04100565, 22.00219245, 15.0079305, 12.99743415, 22.9932822, 13.9885239, 27.0142749, 16.3671393, 12.2895129, 28.68496905, 16.56535725, 32.70596175, 46.01488125, 24.94714485, 10.8170367, 19.68021075, 15.0079305, 26.41962105, 21.9738756, 15.71585175, 21.26595435, 13.28060265, 11.6099085, 15.5742675, 25.96655145, 20.5013994, 15.99902025, 18.03783345, 11.07188835, 32.59269435, 29.7326925, 15.82911915, 13.4788206, 22.11545985, 17.6130807, 22.3136778, 17.01842685, 24.8211230265233, 13.237941302509, 22.3448026530466, 26.8162566663605, 19.755485530466, 28.9524567137097, 35.9159180773958, 29.0510074712366, 29.6768770591437, 19.74645255681, 21.3046743438172, 18.2600040043011, 14.1888055630824, 13.2245440831541, 14.2163781231183, 19.9802103525986, 56.1211624398027, 13.9762431155914, 26.4956908674731, 29.4013819718638, 26.8419717732975, 44.6725035525986, 14.7828541642548, 24.4708500199821, 10.5834818923835, 20.2093501674731, 14.2639281024194, 17.2504254149642, 19.7845974174731, 10.850022277957, 16.4476927547907, 20.9176435624552, 22.8783063162186, 25.7326244974014, 20.1825218974014, 51.1908599407987, 40.9448287612007, 20.2191781781362, 10.3501469886201, 21.1253173781362, 13.4899172867384, 23.1471303187276, 12.8374587906722, 16.9906343861111, 13.1835697522092, 17.8847127055556, 32.4731512323477, 17.6332611074373, 13.4532405190011, 19.4829400781362, 24.2590318624552, 26.5715576967742, 19.0041586430108, 28.5379041193548, 29.7763011256272, 32.1823265123117, 29.7879391141577, 14.0165763547689, 37.6846187388183, 16.3880639974014, 13.8338638285842, 44.6845644331541, 18.6545178642578, 11.2407237620968, 34.0711681997412, 29.0336803177268, 18.1338299396953, 39.7917534240684, 10.6510092909498, 16.2566291560036, 28.5616029884409, 38.8678199534946, 15.4433570447133, 17.2045135497178, 49.4081574106672, 32.6989511276381, 38.5789940244859, 32.1769916573031, 28.9463686859436, 13.4928541224532, 19.5413894417691, 10.7006215291469, 29.8260981653798, 25.4362115265858, 11.5257100913926, 16.8079233526533, 27.4408077645845, 40.6526894052778, 18.8694236080065), ...4 = c(43.01329515, 25.00377855, 15.99902025, 12.99743415, 47.99706075, 15.99902025, 62.0139015, 12.5160477, 20.13328035, 18.4625862, 16.7635752, 31.4317035, 88.914909, 47.82715965, 10.50555135, 14.18674185, 13.28060265, 72.3778686, 21.9738756, 12.82753305, 28.74160275, 46.69448565, 8.6083224, 15.291099, 23.6162529, 15.8008023, 33.27229875, 18.0661503, 7.95703485, 44.76893985, 22.22872725, 21.03941955, 26.92932435, 22.65348, 46.07151495, 15.9140697, 22.4835789, 17.7829818, 18.2384985351852, 20.5132854851852, 61.5926915188615, 15.693652737963, 19.5663315662037, 24.3550255328704, 53.0975022597222, 36.7972078271926, 36.7901429763889, 18.8871641546296, 20.9930987768519, 20.1431562884259, 10.6699463958333, 15.75360755, 37.4331277462963, 54.1371851226852, 19.1322272638889, 25.599830762963, 33.3566375162037, 19.421600999537, 43.1187841560185, 11.9100427961142, 15.1950489439815, 20.8816316998207, 63.5722125117055, 21.3153340421296, 17.4206699247302, 42.4256331148148, 26.851255354471, 13.8370396062451, 65.4289660486111, 70.8573662263666, 29.3347708393519, 30.1223113805556, 104.141421110648, 53.9017718844937, 50.7707224048161, 9.85083922838523, 16.679586024537, 8.50117283796296, 29.7760417518519, 12.3623151717593, 58.2226773143519, 43.8683067041667, 18.6122984347222, 236.356918314815, 26.518730025, 18.768390700463, 13.0113303819444, 27.8125653564815, 63.6389740583333, 80.2297640347222, 23.5851393240741, 29.110683174537, 26.2230636560185, 18.1385155833333, 35.5873651333171, 71.1575933980326, 14.1058989912037, 22.352831962963, 37.7497695597222, 13.9331137675926, 35.9453219891346, 66.8659299971482, 25.6415400254835, 15.1121959384259, 76.2625002964008, 19.6161482467593, 30.3616062425926, 50.555977574537, 48.0870803657407, 60.781296601654, 17.5123175343251, 46.3781020162159, 32.9047155318093, 45.2884006349093, 39.7311056806747, 26.0169754879377, 32.1970505053614, 22.6549346464934, 16.8551283466882, 22.976903453078, 24.6695897641777, 10.0811787631618, 22.3981217825916, 58.8947786812898, 75.1529521249874, 15.0698117186505), ...5 = c(53.0091432, 44.99547465, 38.0012127, 44.0043849, 60.00340515, 38.99230245, 51.536667, 54.7081542, 31.0919013, 60.3715242, 73.48222575, 68.526777, 147.813957, 79.0040115, 47.6289417, 58.07785935, 59.8051872, 96.19233945, 59.21053335, 57.9929088, 122.6685942, 66.4879638, 13.90357335, 30.89368335, 61.3342971, 35.6225973, 75.8325243, 28.91150385, 14.80971255, 95.17293285, 41.71072005, 49.5544875, 58.58756265, 54.11350035, 61.47588135, 38.02952955, 68.526777, 62.15548575, 77.6784310738351, 50.5600232415771, 131.876932720878, 20.6789463878136, 30.9527021610215, 51.8652541034946, 50.5158733141577, 65.3799359472222, 100.009112523321, 53.1610290997312, 60.1700076922043, 32.2775382972222, 33.8153090258961, 54.401286830914, 95.0948838978495, 76.6519537191756, 57.9907266771505, 100.305556442832, 67.9363689859319, 36.8437233959677, 104.980864599731, 29.1320843302867, 48.3498203616488, 45.5838020353047, 70.4890298277778, 38.6008566758961, 55.4927880633513, 87.7219305972222, 54.7773224196237, 43.3184540353047, 94.7221976139785, 109.994754833695, 69.5983515602151, 65.4988362689964, 130.990821687186, 67.8702794202509, 64.9310106890681, 40.9020659196237, 28.7862263164875, 73.8719355863588, 44.2015371620968, 26.9290029520609, 87.4829120246416, 49.3287477370072, 52.4560850095878, 105.858686949731, 51.1010205514337, 84.4875812418607, 44.0169194196237, 56.9543198177419, 109.201614576703, 155.199816965233, 59.9808227158602, 47.1291171577061, 93.1677987708781, 80.5607447070789, 116.459338258333, 82.8986102315412, 64.9543881602151, 50.5573167326165, 107.571298157258, 67.0962686045699, 77.3657611358944, 70.7801148664875, 73.4220260571224, 30.2768192108423, 53.2795572765233, 39.5983236376344, 119.826015501434, 41.0489109464158, 79.0048065370072, 67.9431183426523, 50.6200062464158, 81.1957762876344, 51.8652033564516, 45.4861804724328, 64.5839189739347, 69.7335909436077, 83.2834162480453, 60.7586179353601, 59.0404232122419, 52.2671818563404, 46.4495093287553, 40.0792220246565, 33.0039252222804, 69.8833876014689, 71.1205502192063, 25.9164851853527), ...6 = c(62.0139015, 60.9944949, 44.0043849, 49.01646735, 62.0139015, 54.9913227, 75.29450415, 45.1370589, 38.59586655, 84.63906465, 62.66518905, 137.9030595, 93.7287735, 81.58084485, 52.58439045, 56.49211575, 59.0123154, 90.18916725, 88.37688885, 86.79114525, 104.00779005, 53.43389595, 61.5041982, 60.1449894, 77.10678255, 61.13607915, 75.57767265, 52.01805345, 56.067363, 108.170367, 79.37213055, 61.64578245, 57.05845275, 63.11825865, 85.99827345, 49.1580516, 67.7339052, 65.89330995, 49.4663906333333, 62.902124174537, 125.42931227963, 56.1662971796296, 49.3735742916667, 89.0394507013889, 92.5179659694444, 86.3792399597222, 70.559909350463, 68.0506344111111, 77.1285445736111, 68.6415301606481, 60.7908582935185, 107.425126938426, 90.4807259277778, 81.396785325, 72.1131410115741, 68.8834469532407, 91.5248660726852, 48.0119183564815, 82.2235674268519, 33.5023294574074, 58.6514503578704, 64.0816433337963, 82.6175561916667, 114.884519368981, 59.435669787037, 93.4450806138889, 110.401979493519, 78.3836627305556, 84.819803062963, 117.287431325463, 86.534895237037, 45.5510617347222, 69.754801874537, 103.916983855093, 69.9525828361111, 71.7655604175926, 52.4842327027778, 78.1433190962963, 50.0991498740741, 33.9123993962963, 107.815794591204, 71.0580761560185, 85.9337739583333, 104.136789033333, 58.433218337963, 56.3486961486111, 105.916555494444, 100.764898941204, 89.4245249023148, 101.514945875463, 62.5367144527778, 80.3241535347222, 50.7403866902778, 52.1234550583333, 106.172281121296, 119.406737793519, 109.830748223148, 98.7653273018519, 110.709881538426, 60.5554089296296, 57.7968757921296, 164.881151758333, 114.807172417593, 42.3015284018519, 47.3479581421296, 69.258295625, 79.6316142773148, 38.6308256240741, 93.6480180388889, 74.1446128060185, 68.0709980717593, 92.146788000463, 79.0773117590429, 89.7252644488388, 53.5003470216826, 62.6669327681478, 74.0358775483401, 49.6010839106274, 62.4195698709396, 39.292332545434, 99.9687981401921, 40.2746960761065, 76.0016770163077, 69.3366089449157, 89.2159743205815, 48.0730413172471 ), ...7 = c(91.0103559, 63.00499125, 62.0139015, 55.9540956, 60.00340515, 88.0087698, 75.80420745, 35.2827951, 85.48857015, 119.63869125, 74.72816715, 93.445605, 125.160477, 73.87866165, 73.3972752, 56.77528425, 42.95666145, 118.8175026, 82.4586672, 93.81372405, 99.42046035, 58.332711, 87.1026306, 72.12301695, 54.73647105, 49.41290325, 98.68422225, 60.7679601, 61.02281175, 178.48110555, 60.22993995, 54.84973845, 64.70400225, 94.43669475, 75.06796935, 59.7485535, 60.45647475, 151.8915834, 77.8770211688172, 76.8059709947133, 95.5358418702509, 45.1915104771505, 44.3152274541219, 79.5500496827957, 73.7685236509857, 61.4291771547491, 97.5867666978495, 88.5714360972222, 116.80599130914, 81.5496015871864, 109.510765562724, 136.904898995341, 164.49342743405, 86.2917435997312, 98.5759449758961, 95.1858395146057, 111.213971651613, 86.007780062724, 136.084454635305, 37.0162295108423, 83.3701686708781, 62.8513968664875, 86.4204719321685, 72.132523562724, 104.871318649552, 109.474532174014, 95.9775948796595, 50.6672348277778, 88.3225895139785, 121.58091591147, 76.8334928077061, 55.6079161882617, 95.6947985246416, 127.831395367742, 49.1690975396953, 86.238831349552, 63.4233667882616, 111.597500887007, 31.898796199552, 48.6903161045699, 106.279244610842, 74.6957567051971, 47.4088856058244, 130.007276330914, 88.8368093008065, 50.7865072945341, 101.199211870251, 75.9300093696237, 73.9893747821685, 103.683178131541, 140.684961650806, 104.768995695161, 57.2737217064516, 58.7820591501792, 92.9597528102151, 99.9310094340502, 94.2899004702509, 115.778989568369, 96.1018067252688, 39.8479145108423, 87.5417785945341, 108.026972772133, 67.422470597043, 70.607930149552, 88.305961399552, 59.7161430551971, 69.4862005951613, 54.6980047913978, 126.661692942025, 127.072473339516, 110.780456578853, 93.7374850757168, 69.9698735972591, 106.738637147415, 64.5152740485102, 87.1268323629885, 43.3975092336417, 52.5152792378864, 63.7137140203338, 84.6634689840074, 83.2759556945253, 47.5837274800544, 86.8166065787247, 112.648942563551, 143.549465228576, 65.8425685705771), ...8 c(88.99985955, 92.9925354, 79.99510125, 69.00816345, 66.00657735, 89.9909493, 44.71230615, 62.49528795, 91.8032277, 83.67629175, 85.14876795, 115.8159165, 124.59414, 66.79944915, 73.057473, 71.6416305, 59.89013775, 79.59866535, 116.8919568, 133.7687994, 100.77966915, 58.02122565, 101.85570945, 97.38164715, 77.61648585, 72.9442056, 95.3145171, 71.358462, 85.71510495, 104.3759091, 96.5604585, 94.71986325, 51.16854795, 87.8388687, 97.6931325, 69.093114, 64.08103155, 116.463431853136, 69.5767840669355, 88.8546045972222, 155.196044768369, 76.1697722321685, 88.3709345302867, 96.0580289428316, 82.8718327085125, 81.7255585009857, 126.300796887814, 113.122145047222, 92.5947124141577, 96.673455249104, 66.9335905003584, 106.393679192832, 124.757342490323, 91.3846322578853, 112.209577888441, 80.9145700066308, 118.335473354122, 136.781803584677, 88.5102859103943, 48.9130787077061, 76.6303862258961, 66.0512009164875, 91.1909307947133, 90.038228628405, 120.433525268996, 127.600344080914, 93.5963237177419, 58.4067678514337, 91.812734312724, 96.4453811221326, 95.4837246570789, 91.6730107876344, 117.778913617742, 107.262417822133, 72.8408169577061, 93.2214045639785, 75.6332406620968, 138.346774728405, 41.828554683871, 82.8804427901434, 121.71458362276, 92.5882337083333, 71.4110021051971, 105.813741985305, 73.4316986108423, 52.584441197043, 149.500585721505, 70.0548212120968, 71.3453354315412, 118.636386403495, 159.896641868369, 124.508495907079, 99.5186897095878, 61.6371723683692, 135.166203807706, 69.8381144227599, 99.953642615233, 96.6851439846774, 113.023966434677, 37.3526316589606, 94.9774214089606, 129.41979472966, 96.4015525926523, 68.4592496014337, 92.3934158102151, 112.763803260842, 87.9348144426523, 115.168451893907, 114.463558550806, 105.081225335125, 115.213396858333, 107.920082583871, 113.556526721806, 87.182534043245, 100.746877538778, 107.820717028533, 61.2195953835266, 54.8629442665856, 71.7839889353526, 69.3780698503958, 64.8880471329152, 84.3745727047643, 86.8773256086014, 115.250098093976, 124.182856141139, 90.1817841662871), ...9 = c(54.00023295, 68.0170737, 60.9944949, 82.99668735, 66.9976671, 79.0040115, 80.2499529, 48.7616157, 78.80579355, 110.5489824, 105.0555135, 100.807986, 122.86681215, 51.8198355, 80.78797305, 79.3438137, 124.96225905, 82.65688515, 113.1541326, 135.6377115, 104.9422461, 84.8372826, 68.49846015, 88.77332475, 103.6963047, 81.69411225, 74.55826605, 67.6772715, 88.914909, 142.5470229, 96.7303596, 67.64895465, 76.3422276, 119.2705722, 79.54203165, 85.0071837, 79.7968833, 85.1213250768518, 91.1265074236111, 94.8002691203704, 101.243139074537, 67.7463156712963, 65.3070462777778, 92.9989154310185, 104.489963079167, 88.6454619365741, 95.6530957324074, 96.2138392805556, 106.431327860185, 82.2418335430556, 71.5570295407407, 113.462384235648, 93.298339900463, 92.4140501217593, 94.4176420546296, 86.020909450463, 103.683457240278, 85.9453104527778, 94.0256634365741, 59.9890719296296, 93.0187547055556, 100.441352710648, 82.4177650833333, 94.4054063787037, 95.6760813236111, 118.294777044907, 108.812652588426, 95.822822037037, 109.342894344444, 98.7759898194444, 98.0270790550926, 94.9162458486111, 119.636593705556, 93.1206604064815, 96.5566130018519, 87.0842770861111, 75.9921124731482, 95.2274690055556, 63.7360728865741, 75.1976675148148, 87.622734224537, 79.9642498671296, 64.7750565680556, 72.1407586800926, 75.4217551796296, 89.185317437963, 106.493555012037, 121.68947793287, 111.078000588426, 137.71209555787, 119.270484802315, 83.6887022212963, 110.169414253241, 106.021782307407, 105.793237360648, 112.292741014815, 92.3540953097222, 88.7946497851852, 88.3137003236111, 48.0344669592593, 56.6142103162037, 100.058725644907, 92.1715215453704, 81.5248229337963, 84.5357605861111, 99.5218416648148, 98.9644192287037, 113.18262424537, 84.0182788921296, 78.1174493814815, 58.5339878689815, 86.7326761986111, 63.3940417265209, 90.5242216237781, 87.7613482821531, 79.4634654046871, 75.4329525046438, 87.8455136741353, 82.7085680835468, 66.420417900437, 87.3192277343693, 64.8283838519554, 90.4344488320088, 101.89113025832, 107.25424417281, 55.0424269132735 ), ...10 = c(75.01133565, 75.01133565, 91.0103559, 78.01292175, 91.0103559, 78.01292175, 57.51152235, 75.5493558, 58.899048, 129.77612355, 102.25214535, 103.78125525, 124.5375063, 68.15865795, 86.083224, 75.12460305, 149.7395028, 108.82165455, 122.92344585, 119.63869125, 108.4535355, 71.1319272, 136.8836529, 92.34124785, 106.10323695, 270.3126501, 75.12460305, 90.98203905, 76.3988613, 91.6899603, 114.76819305, 96.30560685, 95.00303175, 89.33966175, 115.5893817, 53.43389595, 130.17255945, 74.0648187194444, 98.415448994534, 117.077048181541, 111.656418203943, 69.0909318771505, 91.8837125102151, 184.392256445341, 143.99505594095, 111.688557997849, 164.432649392204, 92.4773006723118, 96.031623564785, 98.7507854547491, 89.6331318997312, 116.630034395341, 79.1743862390681, 82.1261387428315, 145.541538245341, 97.1231247972222, 70.2878347179212, 74.8902532053764, 109.844562695968, 99.9151256095878, 80.1571873053764, 93.3414720677419, 112.481429797849, 107.20843988405, 99.7747085415771, 91.5307329947133, 103.970490973387, 120.196790313351, 104.027496818369, 93.228576812724, 119.336712512724, 82.0989383277778, 126.093123072133, 106.900354585932, 89.8837884608423, 100.182088887186, 104.524344200806, 134.879635255824, 91.8319674420251, 133.253513925269, 83.6035035746416, 88.3071285815412, 96.0991509633513, 95.2481568834229, 117.772485658961, 106.50540726586, 128.208598138441, 95.8156103183692, 153.21083736147, 131.853555249731, 152.367387675269, 119.728631925896, 147.733996575896, 85.6276001321685, 83.440402578405, 147.025703180914, 101.382341032796, 77.8944443202509, 94.4307404302867, 59.4824360064516, 91.2871979353047, 100.210777882168, 116.855774158333, 71.9237333120968, 85.1692190083333, 99.4269390558244, 119.594219924642, 69.1883154526882, 122.62561145457, 78.3248299920251, 62.5127111014337, 109.128674160215, 92.5094141691414, 102.214150982881, 113.304196757922, 104.289463219631, 69.3166222008229, 75.6406286742023, 96.6916710132641, 61.1471702956426, 87.6592065685503, 60.3468631148267, 81.8521951100248, 76.5965939733406, 103.143649918913, NA), ...11 = c(111.99314175, 82.99668735, 84.01609395, 135.0147408, 88.99985955, 113.52225165, 117.31670955, 64.19429895, 97.21174605, 109.4729421, 181.22784, 319.980405, 127.1426565, 100.60976805, 156.90366585, 174.6583308, 107.7172974, 126.4064184, 110.35076445, 234.83163705, 71.55667995, 71.4150957, 109.10482305, 119.0440374, 168.3719901, 146.76623355, 107.68898055, 109.4729421, 92.79431745, 139.34721885, 169.02327765, 103.49808675, 99.108975, 269.09502555, 239.7304521, 117.3450264, 165.5403051, 452.789752612037, 112.674668899074, 136.845023123148, 125.390507707407, 147.205406918056, 101.483482708796, 148.538046821759, 93.6385790888889, 104.208804725926, 145.404228024074, 92.5718903412037, 77.9773508921296, 100.475874796296, 108.628243472685, 140.548237839815, 144.128658808796, 84.9861208578704, 82.5432681592593, 121.266910125, 142.538632722222, 193.310132988426, 182.567559116204, 142.72417800787, 104.623069753704, 141.985492772685, 103.156623993981, 114.944911169444, 104.799438282407, 117.003563643981, 117.717515334259, 147.705758665741, 254.736285055556, 120.990908235185, 113.687171081944, 87.6590916615741, 129.361771124537, 107.696933739352, 77.3595366555556, 151.29439501713, 100.562660697685, 138.193744200926, 95.7973893106481, 102.302224223611, 110.082453556481, 108.45808017963, 100.091499776852, 115.70011456713, 72.1630450898148, 114.096978827778, 133.093564884259, 83.1709583342593, 133.803933269444, 182.775128618519, 122.711069475, 148.112857083333, 121.410067533333, 149.270963809722, 104.353972281019, 113.122844228704, 147.872513449074, 112.707443031019, 122.870308057407, 58.9955350444444, 89.6550799958333, 147.303729313889, 75.6135057009259, 106.781442987037, 137.607567926389, 127.527206314815, 234.885299228704, 92.3349552166667, 202.163518497685, 202.821273476389, 143.923798634722, 225.143428851852, 157.530355633389, 187.676065594925, 221.071077738915, 82.7623531446858, 77.798518465568, 129.726331786836, 174.877740649028, 76.0276641003277, 152.010982110292, 102.903773583178, 83.4300837163835, 99.7688463421467, 96.9843391694606, NA), ...12 = c(49.01646735, 63.996081, 65.0154876, 85.99827345, 51.9897366, 155.0064369, 66.5445975, 36.38715225, 206.23161855, 82.0055976, 116.75037255, 489.881505, 168.8816934, 39.38873835, 86.5929273, 65.9216268, 97.8630336, 95.4277845, 76.82361405, 88.99985955, 46.9493373, 61.9006341, 62.863407, 102.81848235, 117.4582938, 71.5283631, 99.5054109, 61.47588135, 98.2594695, 155.94089295, 109.9826454, 61.36261395, 67.02598395, 85.77173865, 132.04147155, 140.9612793, 95.28620025, 226.915825714606, 47.7665338492832, 215.910399075269, 212.148030222133, 90.9036179528674, 44.6233634992832, 82.859771827957, 84.9997408003584, 183.01078660914, 226.450745981093, 151.807529381093, 156.272135815412, 96.0256184980287, 57.7046317643369, 114.181235834857, 157.950002214158, 77.9836407061828, 135.604607512276, 84.7630565917563, 122.853364183602, 101.765599617294, 91.7150293392473, 87.4384406992832, 72.8254067723118, 204.161240689247, 214.597674566667, 70.3557850085125, 75.8190763336022, 49.8698972879928, 44.2102994848566, 126.040684461021, 166.839209497222, 110.586112319803, 68.2977386792115, 147.835203095341, 203.118727268996, 52.2794852999104, 56.9600542336022, 69.8238206723118, 61.674251541129, 129.046414902867, 32.7366637110215, 79.5157277660394, 52.6014922034946, 98.6752400233871, 89.3299859804659, 141.735763754749, 39.2333339886201, 181.927574060394, 74.4077503204301, 145.684661822312, 63.3958957223118, 89.1317680304659, 84.1083689898745, 86.3574610204301, 103.421949269803, 72.9182738610215, 68.2365377453405, 68.8206192947133, 58.5744868285842, 122.020063906004, 178.942193182796, 28.2040562390681, 138.280685162724, 296.330997365233, 173.333545410842, 149.083377365233, 65.756343680914, 159.737685213978, 105.61780765224, 46.7002200658602, 86.7429017277778, 189.154748022133, 96.7353497258961, 68.4664725972222, 499.277855419375, 170.849271829193, 148.879966449353, 60.8120779047451, 91.4588421221316, 43.0376842705498, 108.148547912706, 121.468512697252, 42.6455518427129, 96.4984871785073, 109.87928815051, 85.3031155445198, 58.5462485275265, NA)), row.names c(NA, -126L), class = "data.frame") What I want to do is, instead of having 12 observations by row, I want to have one observation by row. I want to have a single column with 1509 observations instead of 126 rows with 12 columns per row. I tried the following: df = data.frame(matrix(nrow = Length, ncol = 1)) colnames(df) = c("aportes_alajuela") for (row in 1:nrow(alajuela_df)){ for (col in 1:ncol(alajuela_df)){ df[i,1]=alajuela_df[i,j] } } But I am not getting the data in the structure I want. Any help will be greatly appreciated. Best regards, Paul [[alternative HTML version deleted]]
You are not getting the structure you want because the indexes are wrong. They should be something more like this: i <- 0 for (row in 1:nrow(alajuela_df)){ for (col in 1:ncol(alajuela_df)){ i <- i + 1 df[i,1]=alajuela_df[row,col] } } but I think what you are doing can be written much shorter and will run faster: ## transpose here matches your original code df <- data.frame(aportes_alajuela = c(t(alajuela_df))) ## but if you do not want to transpose, then do this df <- data.frame(aportes_alajuela = unlist(alajuela_df, use.names = FALSE)) However, you said you expected 1509 observations, but this gives you 1512 observations. If you want to exclude the 3 NA observations, do something like: df <- df[!is.na(df$aportes_alajuela), , drop = FALSE] On Fri, Oct 27, 2023 at 11:14?PM Paul Bernal <paulbernal07 at gmail.com> wrote:> > Dear friends, > > I have the following dataframe: > dim(alajuela_df) > [1] 126 12 > > dput(alajuela_df) > structure(list(...1 = c(92.9925354, 76.0024254, 44.99547465, > 28.00536465, 120.0068103, 31.9980405, 85.0071837, 40.1532933, > 19.3120917, 113.12581575, 28.45843425, 114.400074, 143.0000925, > 46.439634, 20.7845679, 50.82874575, 36.9818061, 44.6273556, 40.57804605, > 30.38398005, 47.94042705, 36.38715225, 28.06199835, 28.4867511, > 122.86681215, 56.4071652, 35.9057658, 52.669341, 24.94714485, > 54.4249857, 61.164396, 47.88379335, 30.582198, 26.051502, 43.041612, > 64.59073485, 51.6499344, 78.8202902886201, 35.2390173175627, > 82.2394568898745, 47.760850180466, 54.3654763342294, 49.4878058854839, > 32.8813266149642, 38.9301880693548, 51.9506275455197, 55.4404001992832, > 50.7979761262545, 37.1198211413082, 36.9144309425627, 33.7829493281362, > 32.8647492475806, 42.8926863444444, 63.9814428257048, 39.219040238172, > 88.7557324417563, 42.0964144925627, 129.15973304991, 117.872998635484, > 35.4004098300179, 83.4102757505377, 38.6443638074373, 100.491764259319, > 40.219162961828, 35.901029409319, 85.2814714674731, 26.5821299974014, > 33.0141992892473, 52.4006692386201, 62.7450310643369, 33.3732853655914, > 36.4616827405018, 146.501706130466, 59.9869292767025, 132.659282967294, > 29.9692075517921, 45.8436438112007, 29.3028312143369, 49.9042699517921, > 27.4678688861111, 29.8483957580645, 26.1192323867384, 62.1371491517921, > 53.92489050681, 64.5840869873656, 28.4476420455197, 52.9893180218638, > 36.4730500781362, 40.8595060662186, 33.4571194806452, 35.6201445262545, > 47.5373940344086, 62.5177012273297, 31.9702480361111, 29.6637272685484, > 49.9578249978495, 26.1936613831541, 30.8051128442652, 153.165249601165, > 36.7652008047491, 14.3854334390681, 55.9930862447133, 87.5882628859319, > 88.414763059767, 58.6046644034946, 20.5301898890681, 39.0037205346774, > 67.5971386298632, 25.1295804696237, 32.7864973072581, 59.5662701215054, > 56.3503435331631, 25.2768483884409, 120.187620533964, 51.3699688189953, > 42.6889983487868, 34.5183987020052, 32.9513272936733, 20.6141437461215, > 43.4197954932283, 107.258904254306, 23.7548470509806, 48.4457090643702, > 72.3249287581108, 32.7272590911596, 48.6115621286089), ...2 = c(34.9996266, > 22.00219245, 22.9932822, 19.00060635, 35.99071635, 23.9560551, > 44.99547465, 22.00219245, 17.35822905, 38.9639856, 16.4804067, > 93.87035775, 81.2693595, 65.4119235, 14.6114946, 33.32893245, > 23.3330844, 66.68618175, 29.1097218, 18.77407155, 28.1469489, > 20.64298365, 15.31941585, 25.79665035, 39.5869563, 35.9057658, > 28.11863205, 27.09922545, 18.03783345, 52.3295388, 47.99706075, > 21.88892505, 18.8590221, 17.64139755, 29.2796229, 27.750513, > 26.9576412, 36.8932410314484, 19.1194611744253, 37.5166237491071, > 37.9625421619439, 23.444984650496, 37.4408609345785, 43.1033210084325, > 28.1252430606151, 38.4216392645833, 41.0532302780651, 34.4822260610119, > 27.8096188059524, 25.9720387760913, 19.5989670673372, 21.1366557174603, > 34.0091174203373, 111.149568174301, 24.5438738482759, 62.923693488747, > 36.056976280754, 36.934798630754, 47.0895472967433, 23.0987961767857, > 45.1991799260913, 23.0274422095238, 26.8716961246169, 21.5009916962302, > 25.315076619246, 41.2098751296627, 15.6537752838123, 20.1723471152778, > 31.7437694203373, 34.6486999232143, 27.6318028338123, 23.9637897951389, > 50.6646878095238, 33.3208231933532, 38.0673028746602, 19.9469359998016, > 27.0503264451389, 19.8385753555556, 29.0062549955939, 17.231889453373, > 25.3320442555556, 17.651735447619, 37.12988188841, 37.7982565469246, > 33.1890524548611, 15.4283008803571, 33.5040593288314, 24.9726150325397, > 29.0612348127976, 30.2629592267857, 32.8065534719349, 43.3676303365079, > 39.19334780424, 23.9252474159722, 15.8641806903257, 27.51501019685, > 21.5861832758362, 18.5136698379577, 54.9166790494253, 29.2865335598214, > 12.8130786005824, 46.2078437446569, 37.9351942968391, 31.8758398080357, > 25.4830299994048, 17.4062173291544, 19.1528843310516, 37.2160194109127, > 25.3577400835684, 21.3381885368056, 37.5842732179795, 62.4856267757438, > 19.2393143990079, 49.4806272500855, 29.5274325254668, 18.7819282827049, > 19.5089694997422, 25.524181172185, 15.9275217745507, 25.461470312583, > 37.4026236465872, 14.6120197959536, 26.5773978462589, 27.6541154512847, > 22.5193597452548, 27.9919830179818), ...3 = c(24.04100565, 22.00219245, > 15.0079305, 12.99743415, 22.9932822, 13.9885239, 27.0142749, > 16.3671393, 12.2895129, 28.68496905, 16.56535725, 32.70596175, > 46.01488125, 24.94714485, 10.8170367, 19.68021075, 15.0079305, > 26.41962105, 21.9738756, 15.71585175, 21.26595435, 13.28060265, > 11.6099085, 15.5742675, 25.96655145, 20.5013994, 15.99902025, > 18.03783345, 11.07188835, 32.59269435, 29.7326925, 15.82911915, > 13.4788206, 22.11545985, 17.6130807, 22.3136778, 17.01842685, > 24.8211230265233, 13.237941302509, 22.3448026530466, 26.8162566663605, > 19.755485530466, 28.9524567137097, 35.9159180773958, 29.0510074712366, > 29.6768770591437, 19.74645255681, 21.3046743438172, 18.2600040043011, > 14.1888055630824, 13.2245440831541, 14.2163781231183, 19.9802103525986, > 56.1211624398027, 13.9762431155914, 26.4956908674731, 29.4013819718638, > 26.8419717732975, 44.6725035525986, 14.7828541642548, 24.4708500199821, > 10.5834818923835, 20.2093501674731, 14.2639281024194, 17.2504254149642, > 19.7845974174731, 10.850022277957, 16.4476927547907, 20.9176435624552, > 22.8783063162186, 25.7326244974014, 20.1825218974014, 51.1908599407987, > 40.9448287612007, 20.2191781781362, 10.3501469886201, 21.1253173781362, > 13.4899172867384, 23.1471303187276, 12.8374587906722, 16.9906343861111, > 13.1835697522092, 17.8847127055556, 32.4731512323477, 17.6332611074373, > 13.4532405190011, 19.4829400781362, 24.2590318624552, 26.5715576967742, > 19.0041586430108, 28.5379041193548, 29.7763011256272, 32.1823265123117, > 29.7879391141577, 14.0165763547689, 37.6846187388183, 16.3880639974014, > 13.8338638285842, 44.6845644331541, 18.6545178642578, 11.2407237620968, > 34.0711681997412, 29.0336803177268, 18.1338299396953, 39.7917534240684, > 10.6510092909498, 16.2566291560036, 28.5616029884409, 38.8678199534946, > 15.4433570447133, 17.2045135497178, 49.4081574106672, 32.6989511276381, > 38.5789940244859, 32.1769916573031, 28.9463686859436, 13.4928541224532, > 19.5413894417691, 10.7006215291469, 29.8260981653798, 25.4362115265858, > 11.5257100913926, 16.8079233526533, 27.4408077645845, 40.6526894052778, > 18.8694236080065), ...4 = c(43.01329515, 25.00377855, 15.99902025, > 12.99743415, 47.99706075, 15.99902025, 62.0139015, 12.5160477, > 20.13328035, 18.4625862, 16.7635752, 31.4317035, 88.914909, 47.82715965, > 10.50555135, 14.18674185, 13.28060265, 72.3778686, 21.9738756, > 12.82753305, 28.74160275, 46.69448565, 8.6083224, 15.291099, > 23.6162529, 15.8008023, 33.27229875, 18.0661503, 7.95703485, > 44.76893985, 22.22872725, 21.03941955, 26.92932435, 22.65348, > 46.07151495, 15.9140697, 22.4835789, 17.7829818, 18.2384985351852, > 20.5132854851852, 61.5926915188615, 15.693652737963, 19.5663315662037, > 24.3550255328704, 53.0975022597222, 36.7972078271926, 36.7901429763889, > 18.8871641546296, 20.9930987768519, 20.1431562884259, 10.6699463958333, > 15.75360755, 37.4331277462963, 54.1371851226852, 19.1322272638889, > 25.599830762963, 33.3566375162037, 19.421600999537, 43.1187841560185, > 11.9100427961142, 15.1950489439815, 20.8816316998207, 63.5722125117055, > 21.3153340421296, 17.4206699247302, 42.4256331148148, 26.851255354471, > 13.8370396062451, 65.4289660486111, 70.8573662263666, 29.3347708393519, > 30.1223113805556, 104.141421110648, 53.9017718844937, 50.7707224048161, > 9.85083922838523, 16.679586024537, 8.50117283796296, 29.7760417518519, > 12.3623151717593, 58.2226773143519, 43.8683067041667, 18.6122984347222, > 236.356918314815, 26.518730025, 18.768390700463, 13.0113303819444, > 27.8125653564815, 63.6389740583333, 80.2297640347222, 23.5851393240741, > 29.110683174537, 26.2230636560185, 18.1385155833333, 35.5873651333171, > 71.1575933980326, 14.1058989912037, 22.352831962963, 37.7497695597222, > 13.9331137675926, 35.9453219891346, 66.8659299971482, 25.6415400254835, > 15.1121959384259, 76.2625002964008, 19.6161482467593, 30.3616062425926, > 50.555977574537, 48.0870803657407, 60.781296601654, 17.5123175343251, > 46.3781020162159, 32.9047155318093, 45.2884006349093, 39.7311056806747, > 26.0169754879377, 32.1970505053614, 22.6549346464934, 16.8551283466882, > 22.976903453078, 24.6695897641777, 10.0811787631618, 22.3981217825916, > 58.8947786812898, 75.1529521249874, 15.0698117186505), ...5 = c(53.0091432, > 44.99547465, 38.0012127, 44.0043849, 60.00340515, 38.99230245, > 51.536667, 54.7081542, 31.0919013, 60.3715242, 73.48222575, 68.526777, > 147.813957, 79.0040115, 47.6289417, 58.07785935, 59.8051872, > 96.19233945, 59.21053335, 57.9929088, 122.6685942, 66.4879638, > 13.90357335, 30.89368335, 61.3342971, 35.6225973, 75.8325243, > 28.91150385, 14.80971255, 95.17293285, 41.71072005, 49.5544875, > 58.58756265, 54.11350035, 61.47588135, 38.02952955, 68.526777, > 62.15548575, 77.6784310738351, 50.5600232415771, 131.876932720878, > 20.6789463878136, 30.9527021610215, 51.8652541034946, 50.5158733141577, > 65.3799359472222, 100.009112523321, 53.1610290997312, 60.1700076922043, > 32.2775382972222, 33.8153090258961, 54.401286830914, 95.0948838978495, > 76.6519537191756, 57.9907266771505, 100.305556442832, 67.9363689859319, > 36.8437233959677, 104.980864599731, 29.1320843302867, 48.3498203616488, > 45.5838020353047, 70.4890298277778, 38.6008566758961, 55.4927880633513, > 87.7219305972222, 54.7773224196237, 43.3184540353047, 94.7221976139785, > 109.994754833695, 69.5983515602151, 65.4988362689964, 130.990821687186, > 67.8702794202509, 64.9310106890681, 40.9020659196237, 28.7862263164875, > 73.8719355863588, 44.2015371620968, 26.9290029520609, 87.4829120246416, > 49.3287477370072, 52.4560850095878, 105.858686949731, 51.1010205514337, > 84.4875812418607, 44.0169194196237, 56.9543198177419, 109.201614576703, > 155.199816965233, 59.9808227158602, 47.1291171577061, 93.1677987708781, > 80.5607447070789, 116.459338258333, 82.8986102315412, 64.9543881602151, > 50.5573167326165, 107.571298157258, 67.0962686045699, 77.3657611358944, > 70.7801148664875, 73.4220260571224, 30.2768192108423, 53.2795572765233, > 39.5983236376344, 119.826015501434, 41.0489109464158, 79.0048065370072, > 67.9431183426523, 50.6200062464158, 81.1957762876344, 51.8652033564516, > 45.4861804724328, 64.5839189739347, 69.7335909436077, 83.2834162480453, > 60.7586179353601, 59.0404232122419, 52.2671818563404, 46.4495093287553, > 40.0792220246565, 33.0039252222804, 69.8833876014689, 71.1205502192063, > 25.9164851853527), ...6 = c(62.0139015, 60.9944949, 44.0043849, > 49.01646735, 62.0139015, 54.9913227, 75.29450415, 45.1370589, > 38.59586655, 84.63906465, 62.66518905, 137.9030595, 93.7287735, > 81.58084485, 52.58439045, 56.49211575, 59.0123154, 90.18916725, > 88.37688885, 86.79114525, 104.00779005, 53.43389595, 61.5041982, > 60.1449894, 77.10678255, 61.13607915, 75.57767265, 52.01805345, > 56.067363, 108.170367, 79.37213055, 61.64578245, 57.05845275, > 63.11825865, 85.99827345, 49.1580516, 67.7339052, 65.89330995, > 49.4663906333333, 62.902124174537, 125.42931227963, 56.1662971796296, > 49.3735742916667, 89.0394507013889, 92.5179659694444, 86.3792399597222, > 70.559909350463, 68.0506344111111, 77.1285445736111, 68.6415301606481, > 60.7908582935185, 107.425126938426, 90.4807259277778, 81.396785325, > 72.1131410115741, 68.8834469532407, 91.5248660726852, 48.0119183564815, > 82.2235674268519, 33.5023294574074, 58.6514503578704, 64.0816433337963, > 82.6175561916667, 114.884519368981, 59.435669787037, 93.4450806138889, > 110.401979493519, 78.3836627305556, 84.819803062963, 117.287431325463, > 86.534895237037, 45.5510617347222, 69.754801874537, 103.916983855093, > 69.9525828361111, 71.7655604175926, 52.4842327027778, 78.1433190962963, > 50.0991498740741, 33.9123993962963, 107.815794591204, 71.0580761560185, > 85.9337739583333, 104.136789033333, 58.433218337963, 56.3486961486111, > 105.916555494444, 100.764898941204, 89.4245249023148, 101.514945875463, > 62.5367144527778, 80.3241535347222, 50.7403866902778, 52.1234550583333, > 106.172281121296, 119.406737793519, 109.830748223148, 98.7653273018519, > 110.709881538426, 60.5554089296296, 57.7968757921296, 164.881151758333, > 114.807172417593, 42.3015284018519, 47.3479581421296, 69.258295625, > 79.6316142773148, 38.6308256240741, 93.6480180388889, 74.1446128060185, > 68.0709980717593, 92.146788000463, 79.0773117590429, 89.7252644488388, > 53.5003470216826, 62.6669327681478, 74.0358775483401, 49.6010839106274, > 62.4195698709396, 39.292332545434, 99.9687981401921, 40.2746960761065, > 76.0016770163077, 69.3366089449157, 89.2159743205815, 48.0730413172471 > ), ...7 = c(91.0103559, 63.00499125, 62.0139015, 55.9540956, > 60.00340515, 88.0087698, 75.80420745, 35.2827951, 85.48857015, > 119.63869125, 74.72816715, 93.445605, 125.160477, 73.87866165, > 73.3972752, 56.77528425, 42.95666145, 118.8175026, 82.4586672, > 93.81372405, 99.42046035, 58.332711, 87.1026306, 72.12301695, > 54.73647105, 49.41290325, 98.68422225, 60.7679601, 61.02281175, > 178.48110555, 60.22993995, 54.84973845, 64.70400225, 94.43669475, > 75.06796935, 59.7485535, 60.45647475, 151.8915834, 77.8770211688172, > 76.8059709947133, 95.5358418702509, 45.1915104771505, 44.3152274541219, > 79.5500496827957, 73.7685236509857, 61.4291771547491, 97.5867666978495, > 88.5714360972222, 116.80599130914, 81.5496015871864, 109.510765562724, > 136.904898995341, 164.49342743405, 86.2917435997312, 98.5759449758961, > 95.1858395146057, 111.213971651613, 86.007780062724, 136.084454635305, > 37.0162295108423, 83.3701686708781, 62.8513968664875, 86.4204719321685, > 72.132523562724, 104.871318649552, 109.474532174014, 95.9775948796595, > 50.6672348277778, 88.3225895139785, 121.58091591147, 76.8334928077061, > 55.6079161882617, 95.6947985246416, 127.831395367742, 49.1690975396953, > 86.238831349552, 63.4233667882616, 111.597500887007, 31.898796199552, > 48.6903161045699, 106.279244610842, 74.6957567051971, 47.4088856058244, > 130.007276330914, 88.8368093008065, 50.7865072945341, 101.199211870251, > 75.9300093696237, 73.9893747821685, 103.683178131541, 140.684961650806, > 104.768995695161, 57.2737217064516, 58.7820591501792, 92.9597528102151, > 99.9310094340502, 94.2899004702509, 115.778989568369, 96.1018067252688, > 39.8479145108423, 87.5417785945341, 108.026972772133, 67.422470597043, > 70.607930149552, 88.305961399552, 59.7161430551971, 69.4862005951613, > 54.6980047913978, 126.661692942025, 127.072473339516, 110.780456578853, > 93.7374850757168, 69.9698735972591, 106.738637147415, 64.5152740485102, > 87.1268323629885, 43.3975092336417, 52.5152792378864, 63.7137140203338, > 84.6634689840074, 83.2759556945253, 47.5837274800544, 86.8166065787247, > 112.648942563551, 143.549465228576, 65.8425685705771), ...8 > c(88.99985955, > 92.9925354, 79.99510125, 69.00816345, 66.00657735, 89.9909493, > 44.71230615, 62.49528795, 91.8032277, 83.67629175, 85.14876795, > 115.8159165, 124.59414, 66.79944915, 73.057473, 71.6416305, 59.89013775, > 79.59866535, 116.8919568, 133.7687994, 100.77966915, 58.02122565, > 101.85570945, 97.38164715, 77.61648585, 72.9442056, 95.3145171, > 71.358462, 85.71510495, 104.3759091, 96.5604585, 94.71986325, > 51.16854795, 87.8388687, 97.6931325, 69.093114, 64.08103155, > 116.463431853136, 69.5767840669355, 88.8546045972222, 155.196044768369, > 76.1697722321685, 88.3709345302867, 96.0580289428316, 82.8718327085125, > 81.7255585009857, 126.300796887814, 113.122145047222, 92.5947124141577, > 96.673455249104, 66.9335905003584, 106.393679192832, 124.757342490323, > 91.3846322578853, 112.209577888441, 80.9145700066308, 118.335473354122, > 136.781803584677, 88.5102859103943, 48.9130787077061, 76.6303862258961, > 66.0512009164875, 91.1909307947133, 90.038228628405, 120.433525268996, > 127.600344080914, 93.5963237177419, 58.4067678514337, 91.812734312724, > 96.4453811221326, 95.4837246570789, 91.6730107876344, 117.778913617742, > 107.262417822133, 72.8408169577061, 93.2214045639785, 75.6332406620968, > 138.346774728405, 41.828554683871, 82.8804427901434, 121.71458362276, > 92.5882337083333, 71.4110021051971, 105.813741985305, 73.4316986108423, > 52.584441197043, 149.500585721505, 70.0548212120968, 71.3453354315412, > 118.636386403495, 159.896641868369, 124.508495907079, 99.5186897095878, > 61.6371723683692, 135.166203807706, 69.8381144227599, 99.953642615233, > 96.6851439846774, 113.023966434677, 37.3526316589606, 94.9774214089606, > 129.41979472966, 96.4015525926523, 68.4592496014337, 92.3934158102151, > 112.763803260842, 87.9348144426523, 115.168451893907, 114.463558550806, > 105.081225335125, 115.213396858333, 107.920082583871, 113.556526721806, > 87.182534043245, 100.746877538778, 107.820717028533, 61.2195953835266, > 54.8629442665856, 71.7839889353526, 69.3780698503958, 64.8880471329152, > 84.3745727047643, 86.8773256086014, 115.250098093976, 124.182856141139, > 90.1817841662871), ...9 = c(54.00023295, 68.0170737, 60.9944949, > 82.99668735, 66.9976671, 79.0040115, 80.2499529, 48.7616157, > 78.80579355, 110.5489824, 105.0555135, 100.807986, 122.86681215, > 51.8198355, 80.78797305, 79.3438137, 124.96225905, 82.65688515, > 113.1541326, 135.6377115, 104.9422461, 84.8372826, 68.49846015, > 88.77332475, 103.6963047, 81.69411225, 74.55826605, 67.6772715, > 88.914909, 142.5470229, 96.7303596, 67.64895465, 76.3422276, > 119.2705722, 79.54203165, 85.0071837, 79.7968833, 85.1213250768518, > 91.1265074236111, 94.8002691203704, 101.243139074537, 67.7463156712963, > 65.3070462777778, 92.9989154310185, 104.489963079167, 88.6454619365741, > 95.6530957324074, 96.2138392805556, 106.431327860185, 82.2418335430556, > 71.5570295407407, 113.462384235648, 93.298339900463, 92.4140501217593, > 94.4176420546296, 86.020909450463, 103.683457240278, 85.9453104527778, > 94.0256634365741, 59.9890719296296, 93.0187547055556, 100.441352710648, > 82.4177650833333, 94.4054063787037, 95.6760813236111, 118.294777044907, > 108.812652588426, 95.822822037037, 109.342894344444, 98.7759898194444, > 98.0270790550926, 94.9162458486111, 119.636593705556, 93.1206604064815, > 96.5566130018519, 87.0842770861111, 75.9921124731482, 95.2274690055556, > 63.7360728865741, 75.1976675148148, 87.622734224537, 79.9642498671296, > 64.7750565680556, 72.1407586800926, 75.4217551796296, 89.185317437963, > 106.493555012037, 121.68947793287, 111.078000588426, 137.71209555787, > 119.270484802315, 83.6887022212963, 110.169414253241, 106.021782307407, > 105.793237360648, 112.292741014815, 92.3540953097222, 88.7946497851852, > 88.3137003236111, 48.0344669592593, 56.6142103162037, 100.058725644907, > 92.1715215453704, 81.5248229337963, 84.5357605861111, 99.5218416648148, > 98.9644192287037, 113.18262424537, 84.0182788921296, 78.1174493814815, > 58.5339878689815, 86.7326761986111, 63.3940417265209, 90.5242216237781, > 87.7613482821531, 79.4634654046871, 75.4329525046438, 87.8455136741353, > 82.7085680835468, 66.420417900437, 87.3192277343693, 64.8283838519554, > 90.4344488320088, 101.89113025832, 107.25424417281, 55.0424269132735 > ), ...10 = c(75.01133565, 75.01133565, 91.0103559, 78.01292175, > 91.0103559, 78.01292175, 57.51152235, 75.5493558, 58.899048, > 129.77612355, 102.25214535, 103.78125525, 124.5375063, 68.15865795, > 86.083224, 75.12460305, 149.7395028, 108.82165455, 122.92344585, > 119.63869125, 108.4535355, 71.1319272, 136.8836529, 92.34124785, > 106.10323695, 270.3126501, 75.12460305, 90.98203905, 76.3988613, > 91.6899603, 114.76819305, 96.30560685, 95.00303175, 89.33966175, > 115.5893817, 53.43389595, 130.17255945, 74.0648187194444, 98.415448994534, > 117.077048181541, 111.656418203943, 69.0909318771505, 91.8837125102151, > 184.392256445341, 143.99505594095, 111.688557997849, 164.432649392204, > 92.4773006723118, 96.031623564785, 98.7507854547491, 89.6331318997312, > 116.630034395341, 79.1743862390681, 82.1261387428315, 145.541538245341, > 97.1231247972222, 70.2878347179212, 74.8902532053764, 109.844562695968, > 99.9151256095878, 80.1571873053764, 93.3414720677419, 112.481429797849, > 107.20843988405, 99.7747085415771, 91.5307329947133, 103.970490973387, > 120.196790313351, 104.027496818369, 93.228576812724, 119.336712512724, > 82.0989383277778, 126.093123072133, 106.900354585932, 89.8837884608423, > 100.182088887186, 104.524344200806, 134.879635255824, 91.8319674420251, > 133.253513925269, 83.6035035746416, 88.3071285815412, 96.0991509633513, > 95.2481568834229, 117.772485658961, 106.50540726586, 128.208598138441, > 95.8156103183692, 153.21083736147, 131.853555249731, 152.367387675269, > 119.728631925896, 147.733996575896, 85.6276001321685, 83.440402578405, > 147.025703180914, 101.382341032796, 77.8944443202509, 94.4307404302867, > 59.4824360064516, 91.2871979353047, 100.210777882168, 116.855774158333, > 71.9237333120968, 85.1692190083333, 99.4269390558244, 119.594219924642, > 69.1883154526882, 122.62561145457, 78.3248299920251, 62.5127111014337, > 109.128674160215, 92.5094141691414, 102.214150982881, 113.304196757922, > 104.289463219631, 69.3166222008229, 75.6406286742023, 96.6916710132641, > 61.1471702956426, 87.6592065685503, 60.3468631148267, 81.8521951100248, > 76.5965939733406, 103.143649918913, NA), ...11 = c(111.99314175, > 82.99668735, 84.01609395, 135.0147408, 88.99985955, 113.52225165, > 117.31670955, 64.19429895, 97.21174605, 109.4729421, 181.22784, > 319.980405, 127.1426565, 100.60976805, 156.90366585, 174.6583308, > 107.7172974, 126.4064184, 110.35076445, 234.83163705, 71.55667995, > 71.4150957, 109.10482305, 119.0440374, 168.3719901, 146.76623355, > 107.68898055, 109.4729421, 92.79431745, 139.34721885, 169.02327765, > 103.49808675, 99.108975, 269.09502555, 239.7304521, 117.3450264, > 165.5403051, 452.789752612037, 112.674668899074, 136.845023123148, > 125.390507707407, 147.205406918056, 101.483482708796, 148.538046821759, > 93.6385790888889, 104.208804725926, 145.404228024074, 92.5718903412037, > 77.9773508921296, 100.475874796296, 108.628243472685, 140.548237839815, > 144.128658808796, 84.9861208578704, 82.5432681592593, 121.266910125, > 142.538632722222, 193.310132988426, 182.567559116204, 142.72417800787, > 104.623069753704, 141.985492772685, 103.156623993981, 114.944911169444, > 104.799438282407, 117.003563643981, 117.717515334259, 147.705758665741, > 254.736285055556, 120.990908235185, 113.687171081944, 87.6590916615741, > 129.361771124537, 107.696933739352, 77.3595366555556, 151.29439501713, > 100.562660697685, 138.193744200926, 95.7973893106481, 102.302224223611, > 110.082453556481, 108.45808017963, 100.091499776852, 115.70011456713, > 72.1630450898148, 114.096978827778, 133.093564884259, 83.1709583342593, > 133.803933269444, 182.775128618519, 122.711069475, 148.112857083333, > 121.410067533333, 149.270963809722, 104.353972281019, 113.122844228704, > 147.872513449074, 112.707443031019, 122.870308057407, 58.9955350444444, > 89.6550799958333, 147.303729313889, 75.6135057009259, 106.781442987037, > 137.607567926389, 127.527206314815, 234.885299228704, 92.3349552166667, > 202.163518497685, 202.821273476389, 143.923798634722, 225.143428851852, > 157.530355633389, 187.676065594925, 221.071077738915, 82.7623531446858, > 77.798518465568, 129.726331786836, 174.877740649028, 76.0276641003277, > 152.010982110292, 102.903773583178, 83.4300837163835, 99.7688463421467, > 96.9843391694606, NA), ...12 = c(49.01646735, 63.996081, 65.0154876, > 85.99827345, 51.9897366, 155.0064369, 66.5445975, 36.38715225, > 206.23161855, 82.0055976, 116.75037255, 489.881505, 168.8816934, > 39.38873835, 86.5929273, 65.9216268, 97.8630336, 95.4277845, > 76.82361405, 88.99985955, 46.9493373, 61.9006341, 62.863407, > 102.81848235, 117.4582938, 71.5283631, 99.5054109, 61.47588135, > 98.2594695, 155.94089295, 109.9826454, 61.36261395, 67.02598395, > 85.77173865, 132.04147155, 140.9612793, 95.28620025, 226.915825714606, > 47.7665338492832, 215.910399075269, 212.148030222133, 90.9036179528674, > 44.6233634992832, 82.859771827957, 84.9997408003584, 183.01078660914, > 226.450745981093, 151.807529381093, 156.272135815412, 96.0256184980287, > 57.7046317643369, 114.181235834857, 157.950002214158, 77.9836407061828, > 135.604607512276, 84.7630565917563, 122.853364183602, 101.765599617294, > 91.7150293392473, 87.4384406992832, 72.8254067723118, 204.161240689247, > 214.597674566667, 70.3557850085125, 75.8190763336022, 49.8698972879928, > 44.2102994848566, 126.040684461021, 166.839209497222, 110.586112319803, > 68.2977386792115, 147.835203095341, 203.118727268996, 52.2794852999104, > 56.9600542336022, 69.8238206723118, 61.674251541129, 129.046414902867, > 32.7366637110215, 79.5157277660394, 52.6014922034946, 98.6752400233871, > 89.3299859804659, 141.735763754749, 39.2333339886201, 181.927574060394, > 74.4077503204301, 145.684661822312, 63.3958957223118, 89.1317680304659, > 84.1083689898745, 86.3574610204301, 103.421949269803, 72.9182738610215, > 68.2365377453405, 68.8206192947133, 58.5744868285842, 122.020063906004, > 178.942193182796, 28.2040562390681, 138.280685162724, 296.330997365233, > 173.333545410842, 149.083377365233, 65.756343680914, 159.737685213978, > 105.61780765224, 46.7002200658602, 86.7429017277778, 189.154748022133, > 96.7353497258961, 68.4664725972222, 499.277855419375, 170.849271829193, > 148.879966449353, 60.8120779047451, 91.4588421221316, 43.0376842705498, > 108.148547912706, 121.468512697252, 42.6455518427129, 96.4984871785073, > 109.87928815051, 85.3031155445198, 58.5462485275265, NA)), row.names > c(NA, > -126L), class = "data.frame") > > What I want to do is, instead of having 12 observations by row, I want to > have one observation by row. I want to have a single column with 1509 > observations instead of 126 rows with 12 columns per row. > > I tried the following: > df = data.frame(matrix(nrow = Length, ncol = 1)) > colnames(df) = c("aportes_alajuela") > > > > for (row in 1:nrow(alajuela_df)){ > for (col in 1:ncol(alajuela_df)){ > df[i,1]=alajuela_df[i,j] > } > } > > But I am not getting the data in the structure I want. > > Any help will be greatly appreciated. > > Best regards, > Paul > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
?s 04:13 de 28/10/2023, Paul Bernal escreveu:> Dear friends, > > I have the following dataframe: > dim(alajuela_df) > [1] 126 12 > > dput(alajuela_df) > structure(list(...1 = c(92.9925354, 76.0024254, 44.99547465, > 28.00536465, 120.0068103, 31.9980405, 85.0071837, 40.1532933, > 19.3120917, 113.12581575, 28.45843425, 114.400074, 143.0000925, > 46.439634, 20.7845679, 50.82874575, 36.9818061, 44.6273556, 40.57804605, > 30.38398005, 47.94042705, 36.38715225, 28.06199835, 28.4867511, > 122.86681215, 56.4071652, 35.9057658, 52.669341, 24.94714485, > 54.4249857, 61.164396, 47.88379335, 30.582198, 26.051502, 43.041612, > 64.59073485, 51.6499344, 78.8202902886201, 35.2390173175627, > 82.2394568898745, 47.760850180466, 54.3654763342294, 49.4878058854839, > 32.8813266149642, 38.9301880693548, 51.9506275455197, 55.4404001992832, > 50.7979761262545, 37.1198211413082, 36.9144309425627, 33.7829493281362, > 32.8647492475806, 42.8926863444444, 63.9814428257048, 39.219040238172, > 88.7557324417563, 42.0964144925627, 129.15973304991, 117.872998635484, > 35.4004098300179, 83.4102757505377, 38.6443638074373, 100.491764259319, > 40.219162961828, 35.901029409319, 85.2814714674731, 26.5821299974014, > 33.0141992892473, 52.4006692386201, 62.7450310643369, 33.3732853655914, > 36.4616827405018, 146.501706130466, 59.9869292767025, 132.659282967294, > 29.9692075517921, 45.8436438112007, 29.3028312143369, 49.9042699517921, > 27.4678688861111, 29.8483957580645, 26.1192323867384, 62.1371491517921, > 53.92489050681, 64.5840869873656, 28.4476420455197, 52.9893180218638, > 36.4730500781362, 40.8595060662186, 33.4571194806452, 35.6201445262545, > 47.5373940344086, 62.5177012273297, 31.9702480361111, 29.6637272685484, > 49.9578249978495, 26.1936613831541, 30.8051128442652, 153.165249601165, > 36.7652008047491, 14.3854334390681, 55.9930862447133, 87.5882628859319, > 88.414763059767, 58.6046644034946, 20.5301898890681, 39.0037205346774, > 67.5971386298632, 25.1295804696237, 32.7864973072581, 59.5662701215054, > 56.3503435331631, 25.2768483884409, 120.187620533964, 51.3699688189953, > 42.6889983487868, 34.5183987020052, 32.9513272936733, 20.6141437461215, > 43.4197954932283, 107.258904254306, 23.7548470509806, 48.4457090643702, > 72.3249287581108, 32.7272590911596, 48.6115621286089), ...2 = c(34.9996266, > 22.00219245, 22.9932822, 19.00060635, 35.99071635, 23.9560551, > 44.99547465, 22.00219245, 17.35822905, 38.9639856, 16.4804067, > 93.87035775, 81.2693595, 65.4119235, 14.6114946, 33.32893245, > 23.3330844, 66.68618175, 29.1097218, 18.77407155, 28.1469489, > 20.64298365, 15.31941585, 25.79665035, 39.5869563, 35.9057658, > 28.11863205, 27.09922545, 18.03783345, 52.3295388, 47.99706075, > 21.88892505, 18.8590221, 17.64139755, 29.2796229, 27.750513, > 26.9576412, 36.8932410314484, 19.1194611744253, 37.5166237491071, > 37.9625421619439, 23.444984650496, 37.4408609345785, 43.1033210084325, > 28.1252430606151, 38.4216392645833, 41.0532302780651, 34.4822260610119, > 27.8096188059524, 25.9720387760913, 19.5989670673372, 21.1366557174603, > 34.0091174203373, 111.149568174301, 24.5438738482759, 62.923693488747, > 36.056976280754, 36.934798630754, 47.0895472967433, 23.0987961767857, > 45.1991799260913, 23.0274422095238, 26.8716961246169, 21.5009916962302, > 25.315076619246, 41.2098751296627, 15.6537752838123, 20.1723471152778, > 31.7437694203373, 34.6486999232143, 27.6318028338123, 23.9637897951389, > 50.6646878095238, 33.3208231933532, 38.0673028746602, 19.9469359998016, > 27.0503264451389, 19.8385753555556, 29.0062549955939, 17.231889453373, > 25.3320442555556, 17.651735447619, 37.12988188841, 37.7982565469246, > 33.1890524548611, 15.4283008803571, 33.5040593288314, 24.9726150325397, > 29.0612348127976, 30.2629592267857, 32.8065534719349, 43.3676303365079, > 39.19334780424, 23.9252474159722, 15.8641806903257, 27.51501019685, > 21.5861832758362, 18.5136698379577, 54.9166790494253, 29.2865335598214, > 12.8130786005824, 46.2078437446569, 37.9351942968391, 31.8758398080357, > 25.4830299994048, 17.4062173291544, 19.1528843310516, 37.2160194109127, > 25.3577400835684, 21.3381885368056, 37.5842732179795, 62.4856267757438, > 19.2393143990079, 49.4806272500855, 29.5274325254668, 18.7819282827049, > 19.5089694997422, 25.524181172185, 15.9275217745507, 25.461470312583, > 37.4026236465872, 14.6120197959536, 26.5773978462589, 27.6541154512847, > 22.5193597452548, 27.9919830179818), ...3 = c(24.04100565, 22.00219245, > 15.0079305, 12.99743415, 22.9932822, 13.9885239, 27.0142749, > 16.3671393, 12.2895129, 28.68496905, 16.56535725, 32.70596175, > 46.01488125, 24.94714485, 10.8170367, 19.68021075, 15.0079305, > 26.41962105, 21.9738756, 15.71585175, 21.26595435, 13.28060265, > 11.6099085, 15.5742675, 25.96655145, 20.5013994, 15.99902025, > 18.03783345, 11.07188835, 32.59269435, 29.7326925, 15.82911915, > 13.4788206, 22.11545985, 17.6130807, 22.3136778, 17.01842685, > 24.8211230265233, 13.237941302509, 22.3448026530466, 26.8162566663605, > 19.755485530466, 28.9524567137097, 35.9159180773958, 29.0510074712366, > 29.6768770591437, 19.74645255681, 21.3046743438172, 18.2600040043011, > 14.1888055630824, 13.2245440831541, 14.2163781231183, 19.9802103525986, > 56.1211624398027, 13.9762431155914, 26.4956908674731, 29.4013819718638, > 26.8419717732975, 44.6725035525986, 14.7828541642548, 24.4708500199821, > 10.5834818923835, 20.2093501674731, 14.2639281024194, 17.2504254149642, > 19.7845974174731, 10.850022277957, 16.4476927547907, 20.9176435624552, > 22.8783063162186, 25.7326244974014, 20.1825218974014, 51.1908599407987, > 40.9448287612007, 20.2191781781362, 10.3501469886201, 21.1253173781362, > 13.4899172867384, 23.1471303187276, 12.8374587906722, 16.9906343861111, > 13.1835697522092, 17.8847127055556, 32.4731512323477, 17.6332611074373, > 13.4532405190011, 19.4829400781362, 24.2590318624552, 26.5715576967742, > 19.0041586430108, 28.5379041193548, 29.7763011256272, 32.1823265123117, > 29.7879391141577, 14.0165763547689, 37.6846187388183, 16.3880639974014, > 13.8338638285842, 44.6845644331541, 18.6545178642578, 11.2407237620968, > 34.0711681997412, 29.0336803177268, 18.1338299396953, 39.7917534240684, > 10.6510092909498, 16.2566291560036, 28.5616029884409, 38.8678199534946, > 15.4433570447133, 17.2045135497178, 49.4081574106672, 32.6989511276381, > 38.5789940244859, 32.1769916573031, 28.9463686859436, 13.4928541224532, > 19.5413894417691, 10.7006215291469, 29.8260981653798, 25.4362115265858, > 11.5257100913926, 16.8079233526533, 27.4408077645845, 40.6526894052778, > 18.8694236080065), ...4 = c(43.01329515, 25.00377855, 15.99902025, > 12.99743415, 47.99706075, 15.99902025, 62.0139015, 12.5160477, > 20.13328035, 18.4625862, 16.7635752, 31.4317035, 88.914909, 47.82715965, > 10.50555135, 14.18674185, 13.28060265, 72.3778686, 21.9738756, > 12.82753305, 28.74160275, 46.69448565, 8.6083224, 15.291099, > 23.6162529, 15.8008023, 33.27229875, 18.0661503, 7.95703485, > 44.76893985, 22.22872725, 21.03941955, 26.92932435, 22.65348, > 46.07151495, 15.9140697, 22.4835789, 17.7829818, 18.2384985351852, > 20.5132854851852, 61.5926915188615, 15.693652737963, 19.5663315662037, > 24.3550255328704, 53.0975022597222, 36.7972078271926, 36.7901429763889, > 18.8871641546296, 20.9930987768519, 20.1431562884259, 10.6699463958333, > 15.75360755, 37.4331277462963, 54.1371851226852, 19.1322272638889, > 25.599830762963, 33.3566375162037, 19.421600999537, 43.1187841560185, > 11.9100427961142, 15.1950489439815, 20.8816316998207, 63.5722125117055, > 21.3153340421296, 17.4206699247302, 42.4256331148148, 26.851255354471, > 13.8370396062451, 65.4289660486111, 70.8573662263666, 29.3347708393519, > 30.1223113805556, 104.141421110648, 53.9017718844937, 50.7707224048161, > 9.85083922838523, 16.679586024537, 8.50117283796296, 29.7760417518519, > 12.3623151717593, 58.2226773143519, 43.8683067041667, 18.6122984347222, > 236.356918314815, 26.518730025, 18.768390700463, 13.0113303819444, > 27.8125653564815, 63.6389740583333, 80.2297640347222, 23.5851393240741, > 29.110683174537, 26.2230636560185, 18.1385155833333, 35.5873651333171, > 71.1575933980326, 14.1058989912037, 22.352831962963, 37.7497695597222, > 13.9331137675926, 35.9453219891346, 66.8659299971482, 25.6415400254835, > 15.1121959384259, 76.2625002964008, 19.6161482467593, 30.3616062425926, > 50.555977574537, 48.0870803657407, 60.781296601654, 17.5123175343251, > 46.3781020162159, 32.9047155318093, 45.2884006349093, 39.7311056806747, > 26.0169754879377, 32.1970505053614, 22.6549346464934, 16.8551283466882, > 22.976903453078, 24.6695897641777, 10.0811787631618, 22.3981217825916, > 58.8947786812898, 75.1529521249874, 15.0698117186505), ...5 = c(53.0091432, > 44.99547465, 38.0012127, 44.0043849, 60.00340515, 38.99230245, > 51.536667, 54.7081542, 31.0919013, 60.3715242, 73.48222575, 68.526777, > 147.813957, 79.0040115, 47.6289417, 58.07785935, 59.8051872, > 96.19233945, 59.21053335, 57.9929088, 122.6685942, 66.4879638, > 13.90357335, 30.89368335, 61.3342971, 35.6225973, 75.8325243, > 28.91150385, 14.80971255, 95.17293285, 41.71072005, 49.5544875, > 58.58756265, 54.11350035, 61.47588135, 38.02952955, 68.526777, > 62.15548575, 77.6784310738351, 50.5600232415771, 131.876932720878, > 20.6789463878136, 30.9527021610215, 51.8652541034946, 50.5158733141577, > 65.3799359472222, 100.009112523321, 53.1610290997312, 60.1700076922043, > 32.2775382972222, 33.8153090258961, 54.401286830914, 95.0948838978495, > 76.6519537191756, 57.9907266771505, 100.305556442832, 67.9363689859319, > 36.8437233959677, 104.980864599731, 29.1320843302867, 48.3498203616488, > 45.5838020353047, 70.4890298277778, 38.6008566758961, 55.4927880633513, > 87.7219305972222, 54.7773224196237, 43.3184540353047, 94.7221976139785, > 109.994754833695, 69.5983515602151, 65.4988362689964, 130.990821687186, > 67.8702794202509, 64.9310106890681, 40.9020659196237, 28.7862263164875, > 73.8719355863588, 44.2015371620968, 26.9290029520609, 87.4829120246416, > 49.3287477370072, 52.4560850095878, 105.858686949731, 51.1010205514337, > 84.4875812418607, 44.0169194196237, 56.9543198177419, 109.201614576703, > 155.199816965233, 59.9808227158602, 47.1291171577061, 93.1677987708781, > 80.5607447070789, 116.459338258333, 82.8986102315412, 64.9543881602151, > 50.5573167326165, 107.571298157258, 67.0962686045699, 77.3657611358944, > 70.7801148664875, 73.4220260571224, 30.2768192108423, 53.2795572765233, > 39.5983236376344, 119.826015501434, 41.0489109464158, 79.0048065370072, > 67.9431183426523, 50.6200062464158, 81.1957762876344, 51.8652033564516, > 45.4861804724328, 64.5839189739347, 69.7335909436077, 83.2834162480453, > 60.7586179353601, 59.0404232122419, 52.2671818563404, 46.4495093287553, > 40.0792220246565, 33.0039252222804, 69.8833876014689, 71.1205502192063, > 25.9164851853527), ...6 = c(62.0139015, 60.9944949, 44.0043849, > 49.01646735, 62.0139015, 54.9913227, 75.29450415, 45.1370589, > 38.59586655, 84.63906465, 62.66518905, 137.9030595, 93.7287735, > 81.58084485, 52.58439045, 56.49211575, 59.0123154, 90.18916725, > 88.37688885, 86.79114525, 104.00779005, 53.43389595, 61.5041982, > 60.1449894, 77.10678255, 61.13607915, 75.57767265, 52.01805345, > 56.067363, 108.170367, 79.37213055, 61.64578245, 57.05845275, > 63.11825865, 85.99827345, 49.1580516, 67.7339052, 65.89330995, > 49.4663906333333, 62.902124174537, 125.42931227963, 56.1662971796296, > 49.3735742916667, 89.0394507013889, 92.5179659694444, 86.3792399597222, > 70.559909350463, 68.0506344111111, 77.1285445736111, 68.6415301606481, > 60.7908582935185, 107.425126938426, 90.4807259277778, 81.396785325, > 72.1131410115741, 68.8834469532407, 91.5248660726852, 48.0119183564815, > 82.2235674268519, 33.5023294574074, 58.6514503578704, 64.0816433337963, > 82.6175561916667, 114.884519368981, 59.435669787037, 93.4450806138889, > 110.401979493519, 78.3836627305556, 84.819803062963, 117.287431325463, > 86.534895237037, 45.5510617347222, 69.754801874537, 103.916983855093, > 69.9525828361111, 71.7655604175926, 52.4842327027778, 78.1433190962963, > 50.0991498740741, 33.9123993962963, 107.815794591204, 71.0580761560185, > 85.9337739583333, 104.136789033333, 58.433218337963, 56.3486961486111, > 105.916555494444, 100.764898941204, 89.4245249023148, 101.514945875463, > 62.5367144527778, 80.3241535347222, 50.7403866902778, 52.1234550583333, > 106.172281121296, 119.406737793519, 109.830748223148, 98.7653273018519, > 110.709881538426, 60.5554089296296, 57.7968757921296, 164.881151758333, > 114.807172417593, 42.3015284018519, 47.3479581421296, 69.258295625, > 79.6316142773148, 38.6308256240741, 93.6480180388889, 74.1446128060185, > 68.0709980717593, 92.146788000463, 79.0773117590429, 89.7252644488388, > 53.5003470216826, 62.6669327681478, 74.0358775483401, 49.6010839106274, > 62.4195698709396, 39.292332545434, 99.9687981401921, 40.2746960761065, > 76.0016770163077, 69.3366089449157, 89.2159743205815, 48.0730413172471 > ), ...7 = c(91.0103559, 63.00499125, 62.0139015, 55.9540956, > 60.00340515, 88.0087698, 75.80420745, 35.2827951, 85.48857015, > 119.63869125, 74.72816715, 93.445605, 125.160477, 73.87866165, > 73.3972752, 56.77528425, 42.95666145, 118.8175026, 82.4586672, > 93.81372405, 99.42046035, 58.332711, 87.1026306, 72.12301695, > 54.73647105, 49.41290325, 98.68422225, 60.7679601, 61.02281175, > 178.48110555, 60.22993995, 54.84973845, 64.70400225, 94.43669475, > 75.06796935, 59.7485535, 60.45647475, 151.8915834, 77.8770211688172, > 76.8059709947133, 95.5358418702509, 45.1915104771505, 44.3152274541219, > 79.5500496827957, 73.7685236509857, 61.4291771547491, 97.5867666978495, > 88.5714360972222, 116.80599130914, 81.5496015871864, 109.510765562724, > 136.904898995341, 164.49342743405, 86.2917435997312, 98.5759449758961, > 95.1858395146057, 111.213971651613, 86.007780062724, 136.084454635305, > 37.0162295108423, 83.3701686708781, 62.8513968664875, 86.4204719321685, > 72.132523562724, 104.871318649552, 109.474532174014, 95.9775948796595, > 50.6672348277778, 88.3225895139785, 121.58091591147, 76.8334928077061, > 55.6079161882617, 95.6947985246416, 127.831395367742, 49.1690975396953, > 86.238831349552, 63.4233667882616, 111.597500887007, 31.898796199552, > 48.6903161045699, 106.279244610842, 74.6957567051971, 47.4088856058244, > 130.007276330914, 88.8368093008065, 50.7865072945341, 101.199211870251, > 75.9300093696237, 73.9893747821685, 103.683178131541, 140.684961650806, > 104.768995695161, 57.2737217064516, 58.7820591501792, 92.9597528102151, > 99.9310094340502, 94.2899004702509, 115.778989568369, 96.1018067252688, > 39.8479145108423, 87.5417785945341, 108.026972772133, 67.422470597043, > 70.607930149552, 88.305961399552, 59.7161430551971, 69.4862005951613, > 54.6980047913978, 126.661692942025, 127.072473339516, 110.780456578853, > 93.7374850757168, 69.9698735972591, 106.738637147415, 64.5152740485102, > 87.1268323629885, 43.3975092336417, 52.5152792378864, 63.7137140203338, > 84.6634689840074, 83.2759556945253, 47.5837274800544, 86.8166065787247, > 112.648942563551, 143.549465228576, 65.8425685705771), ...8 > c(88.99985955, > 92.9925354, 79.99510125, 69.00816345, 66.00657735, 89.9909493, > 44.71230615, 62.49528795, 91.8032277, 83.67629175, 85.14876795, > 115.8159165, 124.59414, 66.79944915, 73.057473, 71.6416305, 59.89013775, > 79.59866535, 116.8919568, 133.7687994, 100.77966915, 58.02122565, > 101.85570945, 97.38164715, 77.61648585, 72.9442056, 95.3145171, > 71.358462, 85.71510495, 104.3759091, 96.5604585, 94.71986325, > 51.16854795, 87.8388687, 97.6931325, 69.093114, 64.08103155, > 116.463431853136, 69.5767840669355, 88.8546045972222, 155.196044768369, > 76.1697722321685, 88.3709345302867, 96.0580289428316, 82.8718327085125, > 81.7255585009857, 126.300796887814, 113.122145047222, 92.5947124141577, > 96.673455249104, 66.9335905003584, 106.393679192832, 124.757342490323, > 91.3846322578853, 112.209577888441, 80.9145700066308, 118.335473354122, > 136.781803584677, 88.5102859103943, 48.9130787077061, 76.6303862258961, > 66.0512009164875, 91.1909307947133, 90.038228628405, 120.433525268996, > 127.600344080914, 93.5963237177419, 58.4067678514337, 91.812734312724, > 96.4453811221326, 95.4837246570789, 91.6730107876344, 117.778913617742, > 107.262417822133, 72.8408169577061, 93.2214045639785, 75.6332406620968, > 138.346774728405, 41.828554683871, 82.8804427901434, 121.71458362276, > 92.5882337083333, 71.4110021051971, 105.813741985305, 73.4316986108423, > 52.584441197043, 149.500585721505, 70.0548212120968, 71.3453354315412, > 118.636386403495, 159.896641868369, 124.508495907079, 99.5186897095878, > 61.6371723683692, 135.166203807706, 69.8381144227599, 99.953642615233, > 96.6851439846774, 113.023966434677, 37.3526316589606, 94.9774214089606, > 129.41979472966, 96.4015525926523, 68.4592496014337, 92.3934158102151, > 112.763803260842, 87.9348144426523, 115.168451893907, 114.463558550806, > 105.081225335125, 115.213396858333, 107.920082583871, 113.556526721806, > 87.182534043245, 100.746877538778, 107.820717028533, 61.2195953835266, > 54.8629442665856, 71.7839889353526, 69.3780698503958, 64.8880471329152, > 84.3745727047643, 86.8773256086014, 115.250098093976, 124.182856141139, > 90.1817841662871), ...9 = c(54.00023295, 68.0170737, 60.9944949, > 82.99668735, 66.9976671, 79.0040115, 80.2499529, 48.7616157, > 78.80579355, 110.5489824, 105.0555135, 100.807986, 122.86681215, > 51.8198355, 80.78797305, 79.3438137, 124.96225905, 82.65688515, > 113.1541326, 135.6377115, 104.9422461, 84.8372826, 68.49846015, > 88.77332475, 103.6963047, 81.69411225, 74.55826605, 67.6772715, > 88.914909, 142.5470229, 96.7303596, 67.64895465, 76.3422276, > 119.2705722, 79.54203165, 85.0071837, 79.7968833, 85.1213250768518, > 91.1265074236111, 94.8002691203704, 101.243139074537, 67.7463156712963, > 65.3070462777778, 92.9989154310185, 104.489963079167, 88.6454619365741, > 95.6530957324074, 96.2138392805556, 106.431327860185, 82.2418335430556, > 71.5570295407407, 113.462384235648, 93.298339900463, 92.4140501217593, > 94.4176420546296, 86.020909450463, 103.683457240278, 85.9453104527778, > 94.0256634365741, 59.9890719296296, 93.0187547055556, 100.441352710648, > 82.4177650833333, 94.4054063787037, 95.6760813236111, 118.294777044907, > 108.812652588426, 95.822822037037, 109.342894344444, 98.7759898194444, > 98.0270790550926, 94.9162458486111, 119.636593705556, 93.1206604064815, > 96.5566130018519, 87.0842770861111, 75.9921124731482, 95.2274690055556, > 63.7360728865741, 75.1976675148148, 87.622734224537, 79.9642498671296, > 64.7750565680556, 72.1407586800926, 75.4217551796296, 89.185317437963, > 106.493555012037, 121.68947793287, 111.078000588426, 137.71209555787, > 119.270484802315, 83.6887022212963, 110.169414253241, 106.021782307407, > 105.793237360648, 112.292741014815, 92.3540953097222, 88.7946497851852, > 88.3137003236111, 48.0344669592593, 56.6142103162037, 100.058725644907, > 92.1715215453704, 81.5248229337963, 84.5357605861111, 99.5218416648148, > 98.9644192287037, 113.18262424537, 84.0182788921296, 78.1174493814815, > 58.5339878689815, 86.7326761986111, 63.3940417265209, 90.5242216237781, > 87.7613482821531, 79.4634654046871, 75.4329525046438, 87.8455136741353, > 82.7085680835468, 66.420417900437, 87.3192277343693, 64.8283838519554, > 90.4344488320088, 101.89113025832, 107.25424417281, 55.0424269132735 > ), ...10 = c(75.01133565, 75.01133565, 91.0103559, 78.01292175, > 91.0103559, 78.01292175, 57.51152235, 75.5493558, 58.899048, > 129.77612355, 102.25214535, 103.78125525, 124.5375063, 68.15865795, > 86.083224, 75.12460305, 149.7395028, 108.82165455, 122.92344585, > 119.63869125, 108.4535355, 71.1319272, 136.8836529, 92.34124785, > 106.10323695, 270.3126501, 75.12460305, 90.98203905, 76.3988613, > 91.6899603, 114.76819305, 96.30560685, 95.00303175, 89.33966175, > 115.5893817, 53.43389595, 130.17255945, 74.0648187194444, 98.415448994534, > 117.077048181541, 111.656418203943, 69.0909318771505, 91.8837125102151, > 184.392256445341, 143.99505594095, 111.688557997849, 164.432649392204, > 92.4773006723118, 96.031623564785, 98.7507854547491, 89.6331318997312, > 116.630034395341, 79.1743862390681, 82.1261387428315, 145.541538245341, > 97.1231247972222, 70.2878347179212, 74.8902532053764, 109.844562695968, > 99.9151256095878, 80.1571873053764, 93.3414720677419, 112.481429797849, > 107.20843988405, 99.7747085415771, 91.5307329947133, 103.970490973387, > 120.196790313351, 104.027496818369, 93.228576812724, 119.336712512724, > 82.0989383277778, 126.093123072133, 106.900354585932, 89.8837884608423, > 100.182088887186, 104.524344200806, 134.879635255824, 91.8319674420251, > 133.253513925269, 83.6035035746416, 88.3071285815412, 96.0991509633513, > 95.2481568834229, 117.772485658961, 106.50540726586, 128.208598138441, > 95.8156103183692, 153.21083736147, 131.853555249731, 152.367387675269, > 119.728631925896, 147.733996575896, 85.6276001321685, 83.440402578405, > 147.025703180914, 101.382341032796, 77.8944443202509, 94.4307404302867, > 59.4824360064516, 91.2871979353047, 100.210777882168, 116.855774158333, > 71.9237333120968, 85.1692190083333, 99.4269390558244, 119.594219924642, > 69.1883154526882, 122.62561145457, 78.3248299920251, 62.5127111014337, > 109.128674160215, 92.5094141691414, 102.214150982881, 113.304196757922, > 104.289463219631, 69.3166222008229, 75.6406286742023, 96.6916710132641, > 61.1471702956426, 87.6592065685503, 60.3468631148267, 81.8521951100248, > 76.5965939733406, 103.143649918913, NA), ...11 = c(111.99314175, > 82.99668735, 84.01609395, 135.0147408, 88.99985955, 113.52225165, > 117.31670955, 64.19429895, 97.21174605, 109.4729421, 181.22784, > 319.980405, 127.1426565, 100.60976805, 156.90366585, 174.6583308, > 107.7172974, 126.4064184, 110.35076445, 234.83163705, 71.55667995, > 71.4150957, 109.10482305, 119.0440374, 168.3719901, 146.76623355, > 107.68898055, 109.4729421, 92.79431745, 139.34721885, 169.02327765, > 103.49808675, 99.108975, 269.09502555, 239.7304521, 117.3450264, > 165.5403051, 452.789752612037, 112.674668899074, 136.845023123148, > 125.390507707407, 147.205406918056, 101.483482708796, 148.538046821759, > 93.6385790888889, 104.208804725926, 145.404228024074, 92.5718903412037, > 77.9773508921296, 100.475874796296, 108.628243472685, 140.548237839815, > 144.128658808796, 84.9861208578704, 82.5432681592593, 121.266910125, > 142.538632722222, 193.310132988426, 182.567559116204, 142.72417800787, > 104.623069753704, 141.985492772685, 103.156623993981, 114.944911169444, > 104.799438282407, 117.003563643981, 117.717515334259, 147.705758665741, > 254.736285055556, 120.990908235185, 113.687171081944, 87.6590916615741, > 129.361771124537, 107.696933739352, 77.3595366555556, 151.29439501713, > 100.562660697685, 138.193744200926, 95.7973893106481, 102.302224223611, > 110.082453556481, 108.45808017963, 100.091499776852, 115.70011456713, > 72.1630450898148, 114.096978827778, 133.093564884259, 83.1709583342593, > 133.803933269444, 182.775128618519, 122.711069475, 148.112857083333, > 121.410067533333, 149.270963809722, 104.353972281019, 113.122844228704, > 147.872513449074, 112.707443031019, 122.870308057407, 58.9955350444444, > 89.6550799958333, 147.303729313889, 75.6135057009259, 106.781442987037, > 137.607567926389, 127.527206314815, 234.885299228704, 92.3349552166667, > 202.163518497685, 202.821273476389, 143.923798634722, 225.143428851852, > 157.530355633389, 187.676065594925, 221.071077738915, 82.7623531446858, > 77.798518465568, 129.726331786836, 174.877740649028, 76.0276641003277, > 152.010982110292, 102.903773583178, 83.4300837163835, 99.7688463421467, > 96.9843391694606, NA), ...12 = c(49.01646735, 63.996081, 65.0154876, > 85.99827345, 51.9897366, 155.0064369, 66.5445975, 36.38715225, > 206.23161855, 82.0055976, 116.75037255, 489.881505, 168.8816934, > 39.38873835, 86.5929273, 65.9216268, 97.8630336, 95.4277845, > 76.82361405, 88.99985955, 46.9493373, 61.9006341, 62.863407, > 102.81848235, 117.4582938, 71.5283631, 99.5054109, 61.47588135, > 98.2594695, 155.94089295, 109.9826454, 61.36261395, 67.02598395, > 85.77173865, 132.04147155, 140.9612793, 95.28620025, 226.915825714606, > 47.7665338492832, 215.910399075269, 212.148030222133, 90.9036179528674, > 44.6233634992832, 82.859771827957, 84.9997408003584, 183.01078660914, > 226.450745981093, 151.807529381093, 156.272135815412, 96.0256184980287, > 57.7046317643369, 114.181235834857, 157.950002214158, 77.9836407061828, > 135.604607512276, 84.7630565917563, 122.853364183602, 101.765599617294, > 91.7150293392473, 87.4384406992832, 72.8254067723118, 204.161240689247, > 214.597674566667, 70.3557850085125, 75.8190763336022, 49.8698972879928, > 44.2102994848566, 126.040684461021, 166.839209497222, 110.586112319803, > 68.2977386792115, 147.835203095341, 203.118727268996, 52.2794852999104, > 56.9600542336022, 69.8238206723118, 61.674251541129, 129.046414902867, > 32.7366637110215, 79.5157277660394, 52.6014922034946, 98.6752400233871, > 89.3299859804659, 141.735763754749, 39.2333339886201, 181.927574060394, > 74.4077503204301, 145.684661822312, 63.3958957223118, 89.1317680304659, > 84.1083689898745, 86.3574610204301, 103.421949269803, 72.9182738610215, > 68.2365377453405, 68.8206192947133, 58.5744868285842, 122.020063906004, > 178.942193182796, 28.2040562390681, 138.280685162724, 296.330997365233, > 173.333545410842, 149.083377365233, 65.756343680914, 159.737685213978, > 105.61780765224, 46.7002200658602, 86.7429017277778, 189.154748022133, > 96.7353497258961, 68.4664725972222, 499.277855419375, 170.849271829193, > 148.879966449353, 60.8120779047451, 91.4588421221316, 43.0376842705498, > 108.148547912706, 121.468512697252, 42.6455518427129, 96.4984871785073, > 109.87928815051, 85.3031155445198, 58.5462485275265, NA)), row.names > c(NA, > -126L), class = "data.frame") > > What I want to do is, instead of having 12 observations by row, I want to > have one observation by row. I want to have a single column with 1509 > observations instead of 126 rows with 12 columns per row. > > I tried the following: > df = data.frame(matrix(nrow = Length, ncol = 1)) > colnames(df) = c("aportes_alajuela") > > > > for (row in 1:nrow(alajuela_df)){ > for (col in 1:ncol(alajuela_df)){ > df[i,1]=alajuela_df[i,j] > } > } > > But I am not getting the data in the structure I want. > > Any help will be greatly appreciated. > > Best regards, > Paul > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.Hello, Here are two base R way with ?stack and with ?reshape. # 1. With stack() df_long <- stack(alajuela_df)[1] df_long <- df_long[complete.cases(df_long), , drop = FALSE] head(df_long) # 2. With reshape df_long <- reshape( alajuela_df, direction = "long", varying = names(alajuela_df), v.names = "x" )[2] # 1512 rows, only one column dim(df_long) # [1] 1512 1 # there are NA's in the data df_long[complete.cases(df_long), , drop = FALSE] |> dim() # [1] 1509 1 # keep the rows with values not NA df_long <- df_long[complete.cases(df_long), , drop = FALSE] # check the dimensions again dim(df_long) # [1] 1509 1 Hope this helps, Rui Barradas -- Este e-mail foi analisado pelo software antiv?rus AVG para verificar a presen?a de v?rus. www.avg.com
Paul, I have snipped away your long message and want to suggest another approach or way of thinking to consider. You have received other good suggestions and I likely would have used something like that, probably within the dplyr/tidyverse but consider something simpler. You seem to be viewing a data.frame as similar to a matrix that you want to reformat. There are similarities but a data.frame is also different. A Matrix actually may be the right way for you to deal with your data. Can you read it in as a matrix or must it be a data.frame? The thing about a matrix is that underneath, it is just a linear vector which you really seem to want. All your columns seem to be the same kind of numeric and perhaps the order does not matter whether it is row major or column major. So consider my smaller example. I am making a data.frame that is smaller for illustration:> small <- data.frame(A=1:4, B=5:8, C=9:12) > smallA B C 1 1 5 9 2 2 6 10 3 3 7 11 4 4 8 12 Now I am making it a matrix and keeping the columns the same:> small.mat <- as.matrix(small) > small.matA B C [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 11 [4,] 4 8 12 This can be linearized into a vector in many ways such as this:> small.vec <- as.vector(small.mat) > small.vec[1] 1 2 3 4 5 6 7 8 9 10 11 12 You can make that into a data.frame if you like:> revised <- data.frame(colname=small.vec) > revisedcolname 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 Of course, the above can be combined into more of a one-liner or made more efficient. But in some cases, if you know the exact details of your data.frame, you can spell out a way to combine the columns trivially. In my example, I have three columns that can simply be concatenated into a vector like so:> small.onecol <- data.frame(onecol=c(small$A, small$B, small$C)) > small.onecolonecol 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 This is not a generalized solution but is simple enough even with the number of columns you have. You are simply consolidating the vectors into one bigger one. If you want to connect many, there are shorter loops that can do it as in:> cols <- colnames(small) > cols[1] "A" "B" "C"> > new <- vector(mode="numeric", length=0) > for (col in cols) {+ new <- append(new, small[[col]]) + }> new[1] 1 2 3 4 5 6 7 8 9 10 11 12> > new.df <- data.frame(newname=new) > new.dfnewname 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 The number of ways to do what you want is huge. You can pick a way that makes more sense to you, especially the ones others have supplied, or one that seems more efficient. As noted, all methods may also need to deal with your NA issue at some stage.