How to reorder day of year so that seasons line up - r

I am working with seasonal data in Australia that spans from their Spring to Fall. I would like to have a column with day of year. However, when I use the yday function from the lubridate, I receive a distribution like this:
The issue here is that the Australian summer (peak time for data collection) goes through the new year. If I tried to add this variable into the model, it would produce incorrect results.
So my question is:
How can I get a seasonally appropriate 'day of year' column for this dataset
I have included some data here:
structure(list(Date = structure(c(11323, 11323, 11323, 11323,
12784, 11324, 12785, 11324, 12419, 12785, 12786, 12786, 13151,
13151, 13151, 12787, 12421, 15343, 15709, 12787, 14614, 15344,
11327, 15344, 14614, 13154, 15711, 15711, 11328, 13154, 16442,
15712, 15712, 16442, 16442, 13886, 16443, 16443, 16443, 16443,
16444, 16444, 13887, 13157, 13157, 13158, 13158, 11697, 16445,
13158, 13889, 16446, 11698, 15716, 11333, 16447, 13525, 13525,
13160, 15351, 11335, 12430, 14257, 13161, 12796, 13162, 12066,
13162, 13892, 13162, 13893, 16085, 14989, 16815, 16085, 16086,
13164, 16086, 17182, 13894, 17183, 15356, 17183, 13165, 11704,
14992, 13166, 14262, 17184, 12435, 11706, 17185, 14628, 14993,
14628, 14629, 14629, 14994, 13168, 16455, 16456, 12804, 16456,
16456, 13899, 12805, 14996, 14996, 16822, 16457, 13171, 16458,
14997, 12806, 14997, 14998, 13172, 13172, 13172, 14998, 13173,
13173, 12808, 12808, 13173, 17192, 13904, 13174, 13174, 13174,
14271, 13175, 13175, 15001, 17193, 12445, 17194, 13176, 12445,
14272, 16464, 16464, 15734, 13907, 14638, 14639, 13178, 13178,
16465, 14639, 16466, 13179, 13179, 16101, 13179, 13910, 12449,
16467, 13910, 16467, 13181, 15372, 13181, 14277, 16468, 14278,
13182, 14278, 12451, 16469, 16470, 13183, 14279, 16835, 14644,
15010, 13549, 14645, 12819, 12819, 17203, 17203, 12454, 12820,
17203, 12821, 15012, 13916, 13916, 12821, 13917, 15013, 15013,
13187, 13917, 13918, 13553, 17206, 14284, 12457, 16476, 14285,
15380, 14285, 16476, 12825, 12459, 12459, 13920, 16477, 13921,
12460, 16478, 12460, 14287, 16114, 14288, 16844, 11731, 16479,
16480, 11367, 11367, 11367, 16845, 16481, 16481, 16846, 16846,
12829, 12830, 11003, 16482, 13925, 11369, 12465, 16483, 16483,
16483, 14657, 17215, 11371, 14658, 16484, 16484, 17216, 16485,
12467, 16850, 11737, 14295, 12834, 12468, 14295, 16851, 13200,
13200, 16487, 11374, 15026, 11375, 16488, 16488, 12836, 16488,
11376, 14663, 13202, 14663, 14663, 14664, 11742, 15029, 11377,
13203, 16491, 16491, 16491, 13569, 13204, 13205, 14301, 11744,
16492, 13935, 16493, 11380, 16493, 11014, 13936, 16494, 13937,
13937, 13572, 16494, 13208, 11382, 13938, 11016, 13208, 11748,
14670, 16496, 14670, 14670, 11384, 14671, 14306, 14671, 12479,
14672, 16498, 16498, 14672, 14672, 14673, 13942, 12481, 13942,
12481, 14309, 16500, 12482, 13943, 13943, 12849, 12483, 15771,
13944, 16501, 16867, 16502, 13945, 12484, 15406, 17234, 16868,
11024, 16503, 17234, 17235, 17235, 17235, 17235, 16869, 17236,
13948, 13948, 13948, 17236, 15045, 15410, 13949, 16141, 13219,
15046, 12489, 15411, 13950, 13950, 11395, 11395, 11395, 12856,
11395, 15779, 15048, 16874, 12857, 16874, 16875, 16510, 16510,
15049, 15049, 14685, 12859, 16511, 15050, 16146, 16512, 14686,
12860, 12860, 12860, 16513, 16878, 14322, 12861, 11400, 15784,
16514, 15784, 13227, 12862, 16515, 12497, 16515, 16515, 14689,
13594, 14690, 12498, 12864, 12864, 11404, 13595, 11404, 12865,
12499, 12500, 12866, 14327, 16518, 16518, 14693, 14328, 14693,
16519, 16519, 12502, 16520, 14329, 14329, 14329, 12503, 11042,
16521, 11042, 13234, 11409, 12504, 14331, 12504, 12504, 15427,
15427, 13601, 15427, 11775, 13602, 16889, 17255, 12506, 12506,
16160, 12873, 15429, 14334, 12507, 12508, 12508, 11047, 13969,
12508, 13970, 11414, 14336, 13605, 13970, 12876, 17259, 16893,
16163, 13606, 13972, 16894, 16894, 11416, 13607, 13973, 12878,
13243, 11417, 13973, 17262, 12513, 13974, 12513, 12513, 16897,
12514, 12514, 16897, 11419, 13976, 16898, 16898, 13976, 16898,
16169, 12151, 15804, 11421, 16899, 16170, 16535, 12883, 16170,
16535, 11057, 11057, 16171, 13979, 16171, 13980, 13250, 14711,
16537, 13980, 14712, 13981, 15808, 13981, 14712, 14713, 14713,
14713, 16174, 14713, 16905, 15444, 16905, 14349, 14349, 13619,
14715, 12523, 16906, 14350, 14716, 13620, 15446, 12524, 12524,
13621, 13621, 13621, 14352, 12525, 12526, 12526, 12526, 12526,
14718, 12527, 11066, 16910, 12527, 13623, 16911, 12528, 16911,
14720, 16911, 14721, 12529, 13990, 11068, 13990, 14357, 12530,
14722, 14357, 13626, 13627, 12531, 13627, 13992, 13992, 11071,
13993, 11071, 11071, 14359, 13994, 11072, 13994, 14360, 13994,
14361, 11073, 14361, 14361, 14361, 16188, 16188, 14362, 14362,
14362, 11075, 13997, 14363, 14363, 14363, 14364, 16190, 14364,
16190, 16190, 14365, 16191, 16191, 11808, 16191, 14366, 14366,
16192, 11078, 14366, 16193, 16193, 16193, 16193, 16193, 16194,
16194, 16194, 16194, 16194, 12542, 16195, 16195, 12542, 12542,
12543, 12543, 12543, 12543, 16196, 14005, 14371, 16197, 14005,
14005, 12545, 14006, 12545, 14006, 12545, 14007, 14007, 12546,
12546, 12546, 14739, 14008, 12547, 12547, 14008, 14009, 14009,
14740, 12548, 15470, 14741, 14741, 15471, 14741, 14741, 14742,
14742, 14742, 16203, 14742, 14743, 14743, 14743, 14743, 14743,
16205, 16205, 13283, 16205, 16205, 16206, 13284, 13284, 16206,
13284, 16207, 16207, 16207, 16207, 15476, 15477, 15477, 15477,
15477, 15477, 15478, 15478, 15478, 14748, 15478, 15479, 14749,
11827, 14749, 14749, 11828, 11828, 14750, 11828, 14750, 16943,
16943, 16943, 16943, 16943, 11100, 11100, 11100, 11100, 11100,
16945, 16945, 16945, 16945, 16945, 16946, 16946, 16946, 16946,
16946, 16947, 16947, 16947, 16947, 16947, 16948, 16948, 16948,
16948, 16948, 16949, 16949, 16949, 16949, 16949, 16314, 16314,
14853, 16314, 16314, 16315, 16315, 14489, 14489, 14489, 16316,
16316, 16316, 14855, 14490, 16317, 13760, 16317, 16317, 16317,
16318, 16318, 13761, 14126, 13761, 13762, 15223, 13762, 16319,
16319, 12667, 14859, 14859, 17050, 12667, 16321, 11207, 11207,
11207, 11207, 11208, 11208, 14496, 13400, 13400, 16323, 14497,
16323, 13401, 14497, 14498, 16324, 14498, 16324, 13402, 16325,
15229, 11211, 15229, 13403, 15230, 15230, 15961, 17056, 15230,
14866, 15231, 13040, 15231, 15962, 13771, 14867, 14502, 15963,
11580, 14868, 14868, 15233, 16694, 16694, 15965, 14869, 15965,
13043, 14504, 14139, 16696, 12678, 14505, 15966, 14871, 13045,
16697, 16697, 14140, 14872, 11219, 11219, 14872, 13411, 13412,
11220, 15969, 14873, 14873, 14509, 14874, 14509, 14874, 12682,
14875, 12683, 14875, 14875, 14875, 12684, 11223, 14511, 14511,
14876, 14877, 12685, 14877, 14877, 12685, 12686, 16339, 14878,
14147, 14878, 16340, 14879, 14879, 14879, 14879, 11227, 11227,
14880, 14880, 14880, 14881, 14881, 16342, 14881, 14881, 16343,
14882, 14882, 14882, 14882, 11230, 14883, 12691, 14883, 12691,
16345, 14153, 16710, 14884, 14884, 14154, 15615, 14885, 12693,
11232, 14886, 14155, 14155, 14886, 14886, 14887, 14887, 14887,
14887, 14887, 14888, 14888, 14888, 12696, 14523, 14889, 16350,
14889, 15619, 14889, 14890, 14525, 14890, 14525, 14525, 14526,
14891, 14891, 14891, 14526, 14892, 14892, 16353, 16353, 12335,
14893, 14893, 14893, 14893, 14893, 13798, 17085, 14894, 17085,
13068, 14895, 13069, 14895, 14895, 14895, 17087, 14896, 17087,
14896, 12339, 17088, 16358, 16358, 14532, 16358, 14898, 12706,
14898, 14898, 14898, 16360, 14899, 14899, 11246, 14899, 14900,
12708, 14900, 14900, 14900, 14901, 14901, 14901, 16362, 14901,
14902, 14902, 14902, 14537, 14902, 14903, 14903, 14903, 14903,
12711, 14904, 12712, 14904, 12712, 14904, 15635, 14905, 11252,
14905, 11252, 14906, 14906, 12349, 14906, 14906, 14542, 14907,
14542, 14542, 16368, 16369, 14908, 14908, 14177, 16369, 16370,
14909, 14909, 12352, 16370, 14910, 17101, 14910, 14545, 14910,
14911, 11258, 16737, 12719, 14911, 16373, 16373, 14912, 14912,
12720, 14913, 14913, 14913, 14913, 11260, 14914, 16375, 11992,
11627, 14914, 14915, 14915, 14915, 14550, 15280, 14916, 13820,
14551, 14916, 14916, 14917, 14917, 14917, 14917, 14917, 11265,
14553, 16014, 14918, 12726, 11266, 14919, 11266, 16380, 14919,
14920, 12728, 12363, 12363, 14920, 14921, 14921, 17112, 14921,
14921, 14922, 14922, 14922, 11269, 14922, 14923, 14923, 14923,
16384, 14923, 14924, 16385, 14924, 14924, 11271, 16386, 14194,
14925, 16386, 14925, 14926, 16387, 13465, 14926, 11273, 11640,
12005, 14196, 14927, 14196, 14197, 12736, 14928, 14928, 14928,
12737, 13833, 14929, 14929, 11642, 14930, 14930, 14930, 14930,
14930, 17122, 12739, 13470, 13470, 12374, 14932, 12375, 14932,
13471, 13471, 11280, 14933, 14933, 14933, 14202, 14934, 14934,
14203, 14934, 14934, 14204, 14935, 14935, 14935, 14935, 12744,
14936, 14936, 14936, 14936, 16398, 11284, 16398, 16398, 16398,
11285, 14938, 16764, 14938, 12381, 16400, 16400, 12747, 12382,
14208, 14209, 11287, 14209, 16401, 13844, 16402, 15671, 14210,
16402, 12749, 12750, 13846, 16403, 16403, 14211, 15673, 15673,
16404, 11656, 16404, 17135, 17135, 16405, 16405, 17135, 14580,
16771, 12753, 12388, 14580, 13485, 17137, 14581, 14581, 12389,
16773, 16773, 15677, 13486, 11294, 12391, 16044, 14217, 14217,
13122, 12757, 13853, 14218, 17140, 14949, 16776, 17141, 17141,
16046, 14950, 15681, 12759, 15681, 16412, 12759, 14587, 13126,
13126, 16413, 16413, 16414, 16414, 16414, 13492, 16414, 16415,
15684, 16415, 16415, 16415, 16416, 14224, 16416, 14224, 14590,
14591, 14956, 12764, 14591, 16052, 14957, 12400, 11304, 11304,
12765, 14958, 14593, 11305, 16784, 14958, 12402, 12402, 12402,
12402, 12767, 14960, 14595, 14595, 13134, 16421, 12769, 12404,
12769, 14230, 14961, 12770, 12770, 12770, 15327, 12770, 14232,
14963, 12406, 17154, 14232, 17155, 14233, 14233, 17155, 17155,
17156, 17156, 14234, 17156, 12408, 12774, 17157, 12774, 17157,
17157, 11314, 12775, 17158, 12775, 12775, 11315, 11315, 11315,
11315, 11315, 11684, 11684, 13510, 11684, 11684, 13511, 13511,
13511, 11319, 11685, 11320, 12781, 11320, 13512, 12781, 11321,
11321, 11321, 11321, 11321, 11322, 11322, 11322, 11322, 11322
), class = "Date"), DOY = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3,
3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7,
7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11,
11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14,
14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17,
17, 17, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20,
20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23,
24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27,
27, 27, 27, 27, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 30, 30,
30, 30, 30, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 33, 33, 33,
33, 33, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 36, 36, 36, 36,
36, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39,
40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 43,
43, 43, 43, 43, 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 46, 46,
46, 46, 46, 47, 47, 47, 47, 47, 48, 48, 48, 48, 48, 49, 49, 49,
49, 49, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52, 52, 52, 52,
52, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55,
56, 56, 56, 56, 56, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, 59,
59, 59, 59, 59, 60, 60, 60, 60, 60, 61, 61, 61, 61, 61, 62, 62,
62, 62, 62, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 65, 65, 65,
65, 65, 66, 66, 66, 66, 66, 67, 67, 67, 67, 67, 68, 68, 68, 68,
68, 69, 69, 69, 69, 69, 70, 70, 70, 70, 70, 71, 71, 71, 71, 71,
72, 72, 72, 72, 72, 73, 73, 73, 73, 73, 74, 74, 74, 74, 74, 75,
75, 75, 75, 75, 76, 76, 76, 76, 76, 77, 77, 77, 77, 77, 78, 78,
78, 78, 78, 79, 79, 79, 79, 79, 80, 80, 80, 80, 80, 81, 81, 81,
81, 81, 82, 82, 82, 82, 82, 83, 83, 83, 83, 83, 84, 84, 84, 84,
84, 85, 85, 85, 85, 85, 86, 86, 86, 86, 86, 87, 87, 87, 87, 87,
88, 88, 88, 88, 88, 89, 89, 89, 89, 89, 90, 90, 90, 90, 90, 91,
91, 91, 91, 91, 92, 92, 92, 92, 92, 93, 93, 93, 93, 93, 94, 94,
94, 94, 94, 95, 95, 95, 95, 95, 96, 96, 96, 96, 96, 97, 97, 97,
97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 99, 100, 100, 100,
100, 100, 101, 101, 101, 101, 101, 102, 102, 102, 102, 102, 103,
103, 103, 103, 103, 104, 104, 104, 104, 104, 105, 105, 105, 105,
105, 106, 106, 106, 106, 106, 107, 107, 107, 107, 107, 108, 108,
108, 108, 108, 109, 109, 109, 109, 109, 110, 110, 110, 110, 110,
111, 111, 111, 111, 111, 112, 112, 112, 112, 112, 113, 113, 113,
113, 113, 114, 114, 114, 114, 114, 115, 115, 115, 115, 115, 116,
116, 116, 116, 116, 117, 117, 117, 117, 117, 118, 118, 118, 118,
118, 119, 119, 119, 119, 119, 120, 120, 120, 120, 120, 121, 121,
121, 121, 121, 122, 122, 122, 122, 122, 123, 123, 123, 123, 123,
124, 124, 124, 124, 124, 125, 125, 125, 125, 125, 126, 126, 126,
126, 126, 127, 127, 127, 127, 127, 128, 128, 128, 128, 128, 129,
129, 129, 129, 129, 130, 130, 130, 130, 130, 131, 131, 131, 131,
131, 132, 132, 132, 132, 132, 133, 133, 133, 133, 133, 134, 134,
134, 134, 134, 135, 135, 135, 135, 135, 136, 136, 136, 136, 136,
137, 137, 137, 137, 137, 138, 138, 138, 138, 138, 139, 139, 139,
139, 139, 140, 140, 140, 140, 140, 141, 141, 141, 141, 141, 143,
143, 143, 143, 143, 144, 144, 144, 144, 144, 145, 145, 145, 145,
145, 146, 146, 146, 146, 146, 147, 147, 147, 147, 147, 148, 148,
148, 148, 148, 149, 149, 149, 149, 149, 244, 244, 244, 244, 244,
245, 245, 245, 245, 245, 246, 246, 246, 246, 246, 247, 247, 247,
247, 247, 248, 248, 248, 248, 248, 249, 249, 249, 249, 249, 250,
250, 250, 250, 250, 251, 251, 251, 251, 251, 252, 252, 252, 252,
252, 253, 253, 253, 253, 253, 254, 254, 254, 254, 254, 255, 255,
255, 255, 255, 256, 256, 256, 256, 256, 257, 257, 257, 257, 257,
258, 258, 258, 258, 258, 259, 259, 259, 259, 259, 260, 260, 260,
260, 260, 261, 261, 261, 261, 261, 262, 262, 262, 262, 262, 263,
263, 263, 263, 263, 264, 264, 264, 264, 264, 265, 265, 265, 265,
265, 266, 266, 266, 266, 266, 267, 267, 267, 267, 267, 268, 268,
268, 268, 268, 269, 269, 269, 269, 269, 270, 270, 270, 270, 270,
271, 271, 271, 271, 271, 272, 272, 272, 272, 272, 273, 273, 273,
273, 273, 274, 274, 274, 274, 274, 275, 275, 275, 275, 275, 276,
276, 276, 276, 276, 277, 277, 277, 277, 277, 278, 278, 278, 278,
278, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 281, 281,
281, 281, 281, 282, 282, 282, 282, 282, 283, 283, 283, 283, 283,
284, 284, 284, 284, 284, 285, 285, 285, 285, 285, 286, 286, 286,
286, 286, 287, 287, 287, 287, 287, 288, 288, 288, 288, 288, 289,
289, 289, 289, 289, 290, 290, 290, 290, 290, 291, 291, 291, 291,
291, 292, 292, 292, 292, 292, 293, 293, 293, 293, 293, 294, 294,
294, 294, 294, 295, 295, 295, 295, 295, 296, 296, 296, 296, 296,
297, 297, 297, 297, 297, 298, 298, 298, 298, 298, 299, 299, 299,
299, 299, 300, 300, 300, 300, 300, 301, 301, 301, 301, 301, 302,
302, 302, 302, 302, 303, 303, 303, 303, 303, 304, 304, 304, 304,
304, 305, 305, 305, 305, 305, 306, 306, 306, 306, 306, 307, 307,
307, 307, 307, 308, 308, 308, 308, 308, 309, 309, 309, 309, 309,
310, 310, 310, 310, 310, 311, 311, 311, 311, 311, 312, 312, 312,
312, 312, 313, 313, 313, 313, 313, 314, 314, 314, 314, 314, 315,
315, 315, 315, 315, 316, 316, 316, 316, 316, 317, 317, 317, 317,
317, 318, 318, 318, 318, 318, 319, 319, 319, 319, 319, 320, 320,
320, 320, 320, 321, 321, 321, 321, 321, 322, 322, 322, 322, 322,
323, 323, 323, 323, 323, 324, 324, 324, 324, 324, 325, 325, 325,
325, 325, 326, 326, 326, 326, 326, 327, 327, 327, 327, 327, 328,
328, 328, 328, 328, 329, 329, 329, 329, 329, 330, 330, 330, 330,
330, 331, 331, 331, 331, 331, 332, 332, 332, 332, 332, 333, 333,
333, 333, 333, 334, 334, 334, 334, 334, 335, 335, 335, 335, 335,
336, 336, 336, 336, 336, 337, 337, 337, 337, 337, 338, 338, 338,
338, 338, 339, 339, 339, 339, 339, 340, 340, 340, 340, 340, 341,
341, 341, 341, 341, 342, 342, 342, 342, 342, 343, 343, 343, 343,
343, 344, 344, 344, 344, 344, 345, 345, 345, 345, 345, 346, 346,
346, 346, 346, 347, 347, 347, 347, 347, 348, 348, 348, 348, 348,
349, 349, 349, 349, 349, 350, 350, 350, 350, 350, 351, 351, 351,
351, 351, 352, 352, 352, 352, 352, 353, 353, 353, 353, 353, 354,
354, 354, 354, 354, 355, 355, 355, 355, 355, 356, 356, 356, 356,
356, 357, 357, 357, 357, 357, 358, 358, 358, 358, 358, 359, 359,
359, 359, 359, 362, 362, 362, 362, 362, 363, 363, 363, 363, 363,
364, 364, 364, 364, 364, 365, 365, 365, 365, 365, 366, 366, 366,
366, 366)), row.names = c(NA, -1345L), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), groups = structure(list(DOY = c(1,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 244, 245, 246,
247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259,
260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272,
273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285,
286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298,
299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311,
312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350,
351, 352, 353, 354, 355, 356, 357, 358, 359, 362, 363, 364, 365,
366), .rows = list(1:5, 6:10, 11:15, 16:20, 21:25, 26:30, 31:35,
36:40, 41:45, 46:50, 51:55, 56:60, 61:65, 66:70, 71:75, 76:80,
81:85, 86:90, 91:95, 96:100, 101:105, 106:110, 111:115, 116:120,
121:125, 126:130, 131:135, 136:140, 141:145, 146:150, 151:155,
156:160, 161:165, 166:170, 171:175, 176:180, 181:185, 186:190,
191:195, 196:200, 201:205, 206:210, 211:215, 216:220, 221:225,
226:230, 231:235, 236:240, 241:245, 246:250, 251:255, 256:260,
261:265, 266:270, 271:275, 276:280, 281:285, 286:290, 291:295,
296:300, 301:305, 306:310, 311:315, 316:320, 321:325, 326:330,
331:335, 336:340, 341:345, 346:350, 351:355, 356:360, 361:365,
366:370, 371:375, 376:380, 381:385, 386:390, 391:395, 396:400,
401:405, 406:410, 411:415, 416:420, 421:425, 426:430, 431:435,
436:440, 441:445, 446:450, 451:455, 456:460, 461:465, 466:470,
471:475, 476:480, 481:485, 486:490, 491:495, 496:500, 501:505,
506:510, 511:515, 516:520, 521:525, 526:530, 531:535, 536:540,
541:545, 546:550, 551:555, 556:560, 561:565, 566:570, 571:575,
576:580, 581:585, 586:590, 591:595, 596:600, 601:605, 606:610,
611:615, 616:620, 621:625, 626:630, 631:635, 636:640, 641:645,
646:650, 651:655, 656:660, 661:665, 666:670, 671:675, 676:680,
681:685, 686:690, 691:695, 696:700, 701:705, 706:710, 711:715,
716:720, 721:725, 726:730, 731:735, 736:740, 741:745, 746:750,
751:755, 756:760, 761:765, 766:770, 771:775, 776:780, 781:785,
786:790, 791:795, 796:800, 801:805, 806:810, 811:815, 816:820,
821:825, 826:830, 831:835, 836:840, 841:845, 846:850, 851:855,
856:860, 861:865, 866:870, 871:875, 876:880, 881:885, 886:890,
891:895, 896:900, 901:905, 906:910, 911:915, 916:920, 921:925,
926:930, 931:935, 936:940, 941:945, 946:950, 951:955, 956:960,
961:965, 966:970, 971:975, 976:980, 981:985, 986:990, 991:995,
996:1000, 1001:1005, 1006:1010, 1011:1015, 1016:1020, 1021:1025,
1026:1030, 1031:1035, 1036:1040, 1041:1045, 1046:1050, 1051:1055,
1056:1060, 1061:1065, 1066:1070, 1071:1075, 1076:1080, 1081:1085,
1086:1090, 1091:1095, 1096:1100, 1101:1105, 1106:1110, 1111:1115,
1116:1120, 1121:1125, 1126:1130, 1131:1135, 1136:1140, 1141:1145,
1146:1150, 1151:1155, 1156:1160, 1161:1165, 1166:1170, 1171:1175,
1176:1180, 1181:1185, 1186:1190, 1191:1195, 1196:1200, 1201:1205,
1206:1210, 1211:1215, 1216:1220, 1221:1225, 1226:1230, 1231:1235,
1236:1240, 1241:1245, 1246:1250, 1251:1255, 1256:1260, 1261:1265,
1266:1270, 1271:1275, 1276:1280, 1281:1285, 1286:1290, 1291:1295,
1296:1300, 1301:1305, 1306:1310, 1311:1315, 1316:1320, 1321:1325,
1326:1330, 1331:1335, 1336:1340, 1341:1345)), row.names = c(NA,
-269L), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE))

The sample data you gave was not very illustrative, since it contained one instance each of the same day each year. We'll create some data that is perhaps more representative:
library(ggplot2)
set.seed(69)
dates <- as.Date("2015-01-01") +
lubridate::days(round(rnorm(5000, 0, 30))) +
lubridate::years(sample(0:5, 5000, TRUE))
df <- data.frame(Date = dates, DOY = lubridate::yday(dates))
ggplot(df, aes(DOY)) + geom_histogram(binwidth = 1)
The way to get rid of this gap is simply to add 6 months and take the result modulo 366:
ggplot(df, aes((DOY + 183) %% 366)) +
geom_histogram(binwidth = 1) +
lims(x = c(0, 366)) +
labs(x = "DOY")
Created on 2020-08-02 by the reprex package (v0.3.0)

Related

how do I add keys of a sorted dictionary sequentially having no intersection with other value lists

I have a dictionary which contains key pair values as key interprets "nodes " and value is a list of communities it belongs to. arranging them according to non-increasing order based on length of list value ,i need to create a list of keys starting from the top rank key and iterate over all keys to find keys with no intersection in their list values with previously added key
this is a dictionary
" {'2179': [15, 197, 363, 594, 766, 865, 1150, 1417, 1575, 1615, 1617, 1618, 1621, 1623, 1624, 1625, 1627], '2188': [15, 363, 766, 1150, 1417, 1616, 1617, 1618, 1619, 1620, 1622, 1624, 1625, 1626, 1629], '2180': [197, 594, 1150, 1575, 1616, 1617, 1618, 1619, 1620, 1622, 1624, 1625, 1626, 1629, 2201], '2195': [1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629], '2452': [1757, 1758, 1759, 1760, 1761, 1762, 1763, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772], '238': [57, 65, 76, 213, 251, 1080, 1126, 1448, 1896, 1897, 1898, 1899, 1900], '6974': [14, 122, 137, 491, 641, 660, 675, 1046, 1800, 2054, 2371], '124': [19, 66, 70, 113, 123, 159, 276, 297, 826, 2122], '3224': [18, 36, 44, 215, 230, 419, 1139, 1259, 2153], '100': [19, 66, 113, 297, 635, 826, 1356, 2122], '553': [40, 50, 133, 135, 192, 526, 1677,
1829]}"
.
I need to add keys iteratively to the list which have no intersection with list values of previously added key and next key to be added. this is a code i tried
"this is a code i tried.
k=len(new_dict)
seed=list(new_dict.keys())[0]
print(seed)
CummunitySet=[]
CommunitySet=set(new_dict.get(seed))
print(CommunitySet)
seedSet=set(seed)
Index=1
while ((seedCount < k) & (Index < count)):
seed=list(new_dict.keys())[Index]
if(set(new_dict.get(seed)).difference(CommunitySet)!=set()):
CommunitySet = CommunitySet.union(new_dict.get(seed))
print(CommunitySet)
seedSet = seedSet.union(set(seed))
Index=Index+1
seedCount=seedCount+1
else:
Index=Index+1
Index=Index+1
print(seedSet)
thankyou.
Maybe you could utilize set.intersection:
def main() -> None:
data = {
'2179': [15, 197, 363, 594, 766, 865, 1150, 1417, 1575, 1615, 1617, 1618, 1621, 1623, 1624, 1625, 1627],
'2188': [15, 363, 766, 1150, 1417, 1616, 1617, 1618, 1619, 1620, 1622, 1624, 1625, 1626, 1629],
'2180': [197, 594, 1150, 1575, 1616, 1617, 1618, 1619, 1620, 1622, 1624, 1625, 1626, 1629, 2201],
'2195': [1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629],
'2452': [1757, 1758, 1759, 1760, 1761, 1762, 1763, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772],
'238': [57, 65, 76, 213, 251, 1080, 1126, 1448, 1896, 1897, 1898, 1899, 1900],
'6974': [14, 122, 137, 491, 641, 660, 675, 1046, 1800, 2054, 2371],
'124': [19, 66, 70, 113, 123, 159, 276, 297, 826, 2122],
'3224': [18, 36, 44, 215, 230, 419, 1139, 1259, 2153],
'100': [19, 66, 113, 297, 635, 826, 1356, 2122],
'553': [40, 50, 133, 135, 192, 526, 1677, 1829]
}
new_data = {}
used_values = set()
for key, values in data.items():
values_set = set(values)
if values_set.intersection(used_values): # Equivalant to `values_set & used_values`.
continue
used_values |= values_set
new_data[key] = values
print(new_data)
if __name__ == '__main__':
main()
Output:
{
'2179': [15, 197, 363, 594, 766, 865, 1150, 1417, 1575, 1615, 1617, 1618, 1621, 1623, 1624, 1625, 1627],
'2452': [1757, 1758, 1759, 1760, 1761, 1762, 1763, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772],
'238': [57, 65, 76, 213, 251, 1080, 1126, 1448, 1896, 1897, 1898, 1899, 1900],
'6974': [14, 122, 137, 491, 641, 660, 675, 1046, 1800, 2054, 2371],
'124': [19, 66, 70, 113, 123, 159, 276, 297, 826, 2122],
'3224': [18, 36, 44, 215, 230, 419, 1139, 1259, 2153],
'553': [40, 50, 133, 135, 192, 526, 1677, 1829]
}
Note: Indentation in output has been added manually for readability.

Replace a single value in data.table column if it doesn't meet a specific criteria

I have the following data.table:
> head(sample)
WeekEndingDate Totals_1 Totals_2
1: 2021-06-05 0 0
2: 2021-06-12 0 0
3: 2021-06-19 0 0
4: 2021-06-26 0 0
5: 2021-07-03 0 0
6: 2021-07-10 0 0
> dput(sample)
structure(list(WeekEndingDate = structure(c(18783, 18790, 18797,
18804, 18811, 18818, 18825, 18832, 18839, 18846, 18853, 18860,
18867, 18874, 18881, 18888, 18895, 18902, 18909, 18916, 18923,
18930, 18937, 18944, 18951, 18958, 18965, 18972, 18979, 18986,
18993, 19000, 19007, 19014, 19021, 19028, 19035, 19042, 19049,
19056, 19063, 19070, 19077, 19084, 19091, 19098, 19105, 19112,
19119, 19126, 19133, 19140, 19147, 19154, 19161, 19168, 19175,
19182, 19189, 19196, 19203, 19210, 19217, 19224, 19231, 19238,
19245, 19252, 19259, 19266, 19273, 19280, 19287, 19294, 19301,
19308, 19315, 19322, 19329, 19336, 19343, 19350, 19357, 19364,
19371, 19378, 19385, 19392, 19399, 19406, 19413, 19420, 19427,
19434, 19441, 19448, 19455, 19462, 19469, 19476, 19483, 19490,
19497, 19504, 19511, 19518, 19525), class = "Date"), Totals_1 = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 3, 5, 6, 8,
10, 12, 15, 18, 21, 24, 27, 27, 28, 32, 37, 42, 48, 54, 61, 68,
74, 81, 90, 98, 106, 116, 123, 123, 128, 136, 145, 155, 164,
173, 181, 191, 200, 208, 216, 225, 236, 243, 247, 251, 254, 259,
266, 271, 278, 288, 296, 304, 313, 326, 333, 341, 351, 360, 369,
376, 384, 392, 400, 409, 409, 412, 423, 428, 432, 436, 440, 442,
443, 443, 444, 445, 446, 446, 446, 446, 446, 446, 446, 447, 447,
447, 447, 447, 447), Totals_2 = c(0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 5, 6, 8, 10, 13, 15, 18,
18, 19, 22, 26, 30, 35, 40, 45, 51, 57, 63, 69, 76, 83, 91, 98,
98, 100, 108, 117, 124, 131, 140, 146, 155, 163, 170, 178, 185,
192, 199, 207, 210, 213, 217, 221, 229, 236, 244, 253, 260, 268,
276, 284, 292, 300, 308, 316, 323, 330, 339, 347, 355, 355, 357,
364, 372, 381, 389, 398, 407, 413, 418, 422, 424, 426, 427, 427,
428, 429, 429, 429, 429, 429, 429, 429, 429, 429)), row.names = c(NA,
-107L), class = c("data.table", "data.frame"))
Within the same environment I have defined a variable x_date which has a specific date. For this example the value is 2023-09-30. Now I have been able to identify the row with the max value using the statement below:
> class(x_date)
[1] "Date"
> x_date
[1] "2023-09-30"
> sample[sample[,.I[which.max(WeekEndingDate)]]]
WeekEndingDate Totals_1 Totals_2
1: 2023-06-17 447 429
However, what I'm trying to do is if the maximum WeekEndingDate is before x_date
than I want to update that value to x_date otherwise the maximum value is fine. I was thinking something like this would work, but this replaces all values in the column instead of just the max:
max(sample$WeekEndingDate) <- ifelse(max(sample$WeekEndingDate) < x_date, x_date, max(sample$WeekEndingDate))
library(data.table)
x_date <- as.Date('2023-09-30')
sample[WeekEndingDate==max(WeekEndingDate),WeekEndingDate:=ifelse(WeekEndingDate<x_date,x_date,WeekEndingDate)]

How to identify the main peaks in data that contains multiple broad peaks

I've got some data that looks like it contains 23 peaks. The x-axis is time and y-axis is peak. However, each peak is quite broad, including several smaller peaks. I'd like to remove the smaller peaks, so I'm just left with the time for each main peak.
I'd be very grateful for some help!
time <- c(1562, 1563, 1564, 1565, 1566, 1810, 1811, 1812, 1813, 1814,
2058, 2059, 2060, 2061, 2306, 2307, 2308, 2309, 2310, 2560, 2561,
2562, 2563, 2564, 3064, 3065, 3066, 3067, 3580, 3581, 3582, 3583,
3584, 4095, 4096, 4097, 4098, 4099, 4610, 4611, 4612, 4613, 4614,
5128, 5129, 5130, 5131, 5132, 5133, 5637, 5638, 5639, 5640, 5641,
5876, 5877, 5878, 5879, 5880, 5881, 5882, 6125, 6126, 6127, 6128,
6129, 6130, 6607, 6608, 6609, 6610, 6611, 6612, 6613, 7072, 7073,
7074, 7075, 7076, 7077, 7078, 7079, 7519, 7520, 7521, 7522, 7523,
7524, 7525, 7526, 7527, 7528, 7941, 7942, 7943, 7944, 7945, 7946,
7947, 7948, 7949, 8342, 8343, 8344, 8345, 8346, 8347, 8348, 8349,
8350, 8351, 8708, 8709, 8710, 8711, 8712, 8713, 8714, 8715, 8716,
8717, 8718, 9045, 9046, 9047, 9048, 9049, 9050, 9051, 9052, 9053,
9054, 9055, 9352, 9353, 9354, 9355, 9356, 9357, 9358, 9359, 9360,
9361, 9362, 9363, 9624, 9625, 9626, 9627, 9628, 9629, 9630, 9631,
9632, 9633, 9634, 9867, 9868, 9869, 9870, 9871, 9872, 9873, 9874,
9875, 9876)
peak <- c(509, 672, 758, 686, 584, 559, 727, 759, 688, 528, 562, 711,
768, 678, 644, 750, 822, 693, 531, 566, 738, 793, 730, 511, 587,
739, 761, 651, 579, 747, 768, 705, 544, 551, 687, 756, 749, 645,
564, 680, 724, 691, 596, 535, 625, 685, 689, 612, 512, 537, 616,
657, 653, 573, 506, 598, 675, 685, 668, 609, 515, 575, 656, 687,
678, 626, 533, 509, 587, 641, 680, 663, 602, 515, 505, 583, 646,
693, 696, 684, 630, 549, 500, 572, 637, 681, 725, 736, 736, 703,
649, 556, 568, 637, 682, 743, 765, 767, 709, 660, 587, 548, 622,
690, 761, 779, 764, 749, 694, 631, 525, 571, 646, 724, 788, 811,
834, 818, 776, 712, 616, 536, 556, 649, 738, 801, 857, 866, 837,
808, 718, 647, 568, 508, 605, 714, 823, 872, 917, 916, 890, 825,
742, 642, 543, 549, 656, 766, 851, 921, 947, 951, 892, 830, 730,
617, 586, 675, 760, 804, 816, 795, 740, 690, 613, 522)
data <- data.frame(time = time, peak = peak)
ggplot(data, aes(x=time, y=peak)) +
geom_line()
ADDITIONAL QUESTION:
I've been trying to apply this to another data set and it picks out too many peaks. The new data contains a broad normal distribution. I'd like it to pick out just the very highest peak in this distribution, but as you can see from the image, it picks out every individual peak on either side. Is there a modification that can be made to the code to pick them out?
data2 <- data.frame(time = c(5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010,
5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019, 5020, 5021,
5022, 5023, 5024, 5025, 5026, 5027, 5028, 5029, 5030, 5031, 5032,
5033, 5034, 5035, 5036, 5037, 5038, 5039, 5040, 5041, 5042, 5043,
5044, 5045, 5046, 5047, 5048, 5049, 5050, 5051, 5052, 5053, 5054,
5055, 5056, 5057, 5058, 5059, 5060, 5061, 5062, 5063, 5064, 5065,
5066, 5067, 5068, 5069, 5070, 5071, 5072, 5073, 5074, 5075, 5076,
5077, 5078, 5079, 5080, 5081, 5082, 5083, 5084, 5085, 5086, 5087,
5088, 5089, 5090, 5091, 5092, 5093, 5094, 5095, 5096, 5097, 5098,
5099, 5100, 5101, 5102, 5103, 5104, 5105, 5106, 5107, 5108, 5109,
5110, 5111, 5112, 5113, 5114, 5115, 5116, 5117, 5118, 5119, 5120,
5121, 5122, 5123, 5124, 5125, 5126, 5127, 5135, 5136, 5137, 5138,
5139, 5140, 5141, 5142, 5143, 5144, 5145, 5146, 5147, 5148, 5149,
5150, 5151, 5152, 5153, 5154, 5155, 5156, 5157, 5158, 5159, 5160,
5161, 5162, 5163, 5164, 5165, 5166, 5167, 5168, 5169, 5170, 5171,
5172, 5173, 5174, 5175, 5176, 5177, 5178, 5179, 5180, 5181, 5182,
5183, 5184, 5185, 5186, 5187, 5188, 5189, 5190, 5191, 5192, 5193,
5194, 5195, 5196, 5197, 5198, 5199, 5200, 5201, 5202, 5203, 5204,
5205, 5206, 5207, 5208, 5209, 5210, 5211, 5212, 5213, 5214, 5215,
5216, 5217, 5218, 5219, 5220, 5221, 5222, 5223, 5224, 5225, 5226,
5227, 5228, 5229, 5230, 5231, 5232, 5233, 5234, 5235, 5236, 5237,
5238, 5239, 5240, 5241, 5242, 5243, 5244, 5245, 5246, 5247, 5248,
5249, 5250, 5251, 5252, 5253, 5254, 5255, 5256, 5257, 5258, 5259,
5260, 5261, 5262, 5263, 5264, 5265, 5266, 5267, 5268, 5269, 5270,
5271, 5272, 5273, 5274, 5275, 5276, 5277, 5278, 5279, 5280, 5281,
5282, 5283, 5284, 5285, 5286, 5287, 5288, 5289, 5290, 5291, 5292,
5293, 5294, 5295, 5296, 5297, 5298, 5299, 5300, 5301, 5302, 5303,
5304, 5305, 5306, 5307, 5308, 5309, 5310, 5311, 5312, 5313, 5314,
5315, 5316, 5317, 5318, 5319, 5320, 5321, 5322, 5323, 5324, 5325,
5326, 5327, 5328, 5329, 5330, 5331, 5332, 5333, 5334, 5335, 5336,
5337, 5338, 5339, 5340, 5341, 5342, 5343, 5344, 5345, 5346, 5347,
5348, 5349, 5350, 5351, 5352, 5353, 5354, 5355, 5356, 5357, 5358,
5359, 5360, 5361, 5362, 5363, 5364, 5365, 5366, 5367, 5368, 5369,
5370, 5371, 5372, 5373, 5374, 5375, 5376, 5377, 5378, 5379, 5380,
5381, 5382, 5383, 5384, 5385, 5386, 5387, 5388, 5389, 5390, 5391,
5392, 5393, 5394, 5395, 5396, 5397, 5398, 5399, 5400, 5401, 5402,
5403, 5404, 5405, 5406, 5407, 5408, 5409, 5410, 5411, 5412, 5413,
5414, 5415, 5416, 5417, 5418, 5419, 5420, 5421, 5422, 5423, 5424,
5425, 5426, 5427, 5428, 5429, 5430, 5431, 5432, 5433, 5434, 5435,
5436, 5437, 5438, 5439, 5440, 5441, 5442, 5443, 5444, 5445, 5446,
5447, 5448, 5449, 5450, 5451, 5452, 5453, 5454, 5455, 5456, 5457,
5458, 5459, 5460, 5461, 5462, 5463, 5464, 5465, 5466, 5467, 5468,
5469, 5470, 5471, 5472, 5473, 5474, 5475, 5476, 5477, 5478, 5479,
5480, 5481, 5482, 5483, 5484, 5485, 5486, 5487, 5488, 5489, 5490,
5491, 5492, 5493, 5494, 5495, 5496, 5497, 5498, 5499, 5500, 5501,
5502, 5503, 5504, 5505, 5506, 5507, 5508, 5509, 5510, 5511, 5512,
5513, 5514, 5515, 5516, 5517, 5518, 5519, 5520, 5521, 5522, 5523,
5524, 5525, 5526, 5527, 5528, 5529, 5530, 5531, 5532, 5533, 5534,
5535, 5536, 5537, 5538, 5539, 5540, 5541, 5542, 5543, 5544, 5545,
5546, 5547, 5548, 5549, 5550, 5551, 5552, 5553, 5554, 5555, 5556,
5557, 5558, 5559, 5560, 5561, 5562, 5563, 5564, 5565, 5566, 5567,
5568, 5569, 5570, 5571, 5572, 5573, 5574, 5575, 5576, 5577, 5578,
5579, 5580, 5581, 5582, 5583, 5584, 5585, 5586, 5587, 5588, 5589,
5590, 5591, 5592, 5593, 5594, 5595, 5596, 5597, 5598, 5599, 5600,
5601, 5602, 5603, 5604, 5605, 5606, 5607, 5608, 5609, 5610, 5611,
5612, 5613, 5614, 5615, 5616, 5617, 5618, 5619, 5620, 5621, 5622,
5623, 5624, 5625, 5626, 5627, 5628, 5629, 5630, 5631, 5632, 5633,
5634, 5635, 5636, 5637, 5638, 5639, 5640, 5641, 5642, 5643, 5644,
5645, 5646, 5647, 5648, 5649, 5650, 5651, 5652, 5653, 5654, 5655,
5656, 5657, 5658, 5659, 5660, 5661, 5662, 5663, 5664, 5665, 5666,
5667, 5668, 5669, 5670, 5671, 5672, 5673, 5674, 5675, 5676, 5677,
5678, 5679, 5680, 5681, 5682, 5683, 5684, 5685, 5686, 5687, 5688,
5689, 5690, 5691, 5692, 5693, 5694, 5695, 5696, 5697, 5698, 5699,
5700, 5701, 5702, 5703, 5704, 5705, 5706, 5707, 5708, 5709, 5710,
5711, 5712, 5713, 5714, 5715, 5716, 5717, 5718, 5719, 5720, 5721,
5722, 5723, 5724, 5725, 5726, 5727, 5728, 5729, 5730, 5731, 5732,
5733, 5734, 5735, 5736, 5737, 5738, 5739, 5740, 5741, 5742, 5743,
5744, 5745, 5746, 5747, 5748, 5749, 5750, 5751, 5752, 5753, 5754,
5755, 5756, 5757, 5758, 5759, 5760, 5761, 5762, 5763, 5764, 5765,
5766, 5767, 5768, 5769, 5770, 5771, 5772, 5773, 5774, 5775, 5776,
5777, 5778, 5779, 5780, 5781, 5782, 5783, 5784, 5785, 5786, 5787,
5788, 5789, 5790, 5791, 5792, 5793, 5794, 5795, 5796, 5797, 5798,
5799, 5800, 5801, 5802, 5803, 5804, 5805, 5806, 5807, 5808, 5809,
5810, 5811, 5812, 5813, 5814, 5815, 5816, 5817, 5818, 5819, 5820,
5821, 5822, 5823, 5824, 5825, 5826, 5827, 5828, 5829, 5830, 5831,
5832, 5833, 5834, 5835, 5836, 5837, 5838, 5839, 5840, 5841, 5842,
5843, 5844, 5845, 5846, 5847, 5848, 5849, 5850, 5851, 5852, 5853,
5854, 5855, 5856, 5857, 5858, 5859, 5860, 5861, 5862, 5863, 5864,
5865, 5866, 5867, 5868, 5869, 5870, 5871, 5872, 5873, 5874, 5875,
5876, 5885, 5886, 5887, 5888, 5889, 5890, 5891, 5892, 5893, 5894,
5895, 5896, 5897, 5898, 5899, 5900, 5901, 5902, 5903, 5904, 5905,
5906, 5907, 5908, 5909, 5910, 5911, 5912, 5913, 5914, 5915, 5916,
5917, 5918, 5919, 5920, 5921, 5922, 5923, 5924, 5925, 5926, 5927,
5928, 5929, 5930, 5931, 5932, 5933, 5934, 5935, 5936, 5937, 5938,
5939, 5940, 5941, 5942, 5943, 5944, 5945, 5946, 5947, 5948, 5949,
5950, 5951, 5952, 5953, 5954, 5955, 5956, 5957, 5958, 5959, 5960,
5961, 5962, 5963, 5964, 5965, 5966, 5967, 5968, 5969, 5970, 5971,
5972, 5973, 5974, 5975, 5976, 5977, 5978, 5979, 5980, 5981, 5982,
5983, 5984, 5985, 5986, 5987, 5988, 5989, 5990, 5991, 5992, 5993,
5994, 5995, 5996, 5997, 5998, 5999),
peak = c(245, 236, 220, 189, 173, 154, 142, 124, 118, 105, 107, 99,
100, 98, 111, 116, 115, 126, 129, 128, 128, 132, 134, 145, 158,
170, 188, 207, 225, 242, 237, 229, 211, 189, 173, 151, 131, 116,
113, 98, 105, 96, 101, 112, 106, 112, 113, 111, 124, 131, 127,
130, 137, 149, 146, 164, 184, 210, 228, 239, 228, 225, 217, 185,
168, 149, 140, 126, 110, 101, 104, 100, 102, 103, 109, 105, 109,
114, 117, 122, 128, 119, 130, 142, 148, 166, 182, 204, 226, 235,
247, 226, 224, 193, 174, 153, 137, 124, 119, 110, 99, 105, 96,
98, 102, 116, 122, 117, 116, 132, 123, 130, 139, 138, 145, 166,
182, 191, 215, 221, 212, 207, 186, 153, 112, 66, 8, 27, 68, 86,
113, 125, 130, 139, 148, 153, 159, 178, 188, 213, 230, 249, 259,
246, 234, 219, 197, 175, 151, 133, 126, 117, 122, 120, 115, 109,
115, 116, 125, 133, 141, 139, 142, 148, 147, 155, 170, 178, 203,
226, 254, 259, 273, 257, 249, 221, 191, 173, 152, 145, 130, 121,
127, 118, 121, 119, 124, 130, 136, 146, 144, 154, 166, 155, 163,
168, 190, 215, 223, 252, 273, 282, 275, 268, 237, 220, 191, 168,
159, 140, 137, 130, 122, 131, 120, 134, 132, 134, 137, 142, 151,
153, 164, 162, 176, 190, 196, 217, 243, 266, 271, 262, 257, 237,
214, 187, 169, 147, 138, 126, 118, 116, 114, 117, 116, 123, 123,
123, 129, 140, 146, 152, 156, 166, 178, 185, 209, 241, 264, 264,
261, 262, 232, 204, 178, 162, 140, 125, 117, 110, 112, 103, 98,
105, 108, 116, 117, 130, 128, 142, 135, 138, 149, 161, 169, 193,
222, 244, 256, 265, 246, 222, 201, 174, 147, 130, 125, 110, 102,
97, 95, 90, 98, 99, 107, 117, 115, 119, 128, 131, 137, 135, 144,
173, 188, 209, 232, 251, 251, 244, 217, 190, 162, 144, 122, 116,
103, 94, 87, 88, 92, 97, 101, 97, 98, 108, 121, 122, 118, 128,
132, 144, 162, 180, 209, 230, 246, 233, 230, 218, 187, 159, 125,
124, 105, 92, 89, 84, 81, 85, 76, 78, 92, 92, 102, 102, 109,
115, 126, 134, 137, 164, 179, 208, 227, 241, 258, 247, 223, 203,
173, 140, 121, 111, 94, 98, 85, 87, 89, 91, 84, 91, 106, 103,
107, 111, 123, 126, 142, 150, 166, 194, 221, 242, 247, 254, 237,
229, 194, 170, 140, 130, 110, 94, 85, 84, 84, 79, 82, 88, 89,
100, 108, 111, 114, 121, 122, 142, 149, 175, 198, 236, 252, 268,
279, 257, 232, 194, 170, 151, 127, 108, 104, 95, 91, 81, 83,
94, 92, 96, 106, 111, 122, 115, 131, 142, 152, 167, 183, 222,
248, 282, 290, 296, 279, 249, 226, 190, 163, 136, 116, 109, 93,
95, 92, 86, 86, 91, 108, 109, 120, 121, 131, 140, 141, 157, 187,
216, 240, 276, 311, 319, 333, 309, 281, 237, 203, 167, 134, 123,
112, 104, 92, 95, 99, 103, 112, 110, 114, 128, 138, 140, 161,
180, 193, 223, 242, 276, 317, 352, 372, 383, 354, 318, 285, 222,
190, 163, 144, 124, 114, 100, 98, 107, 105, 117, 121, 133, 144,
166, 176, 185, 199, 225, 268, 306, 348, 384, 439, 466, 463, 427,
392, 329, 274, 221, 181, 161, 141, 131, 123, 127, 128, 131, 138,
147, 163, 173, 188, 208, 221, 242, 294, 338, 380, 468, 518, 568,
596, 604, 554, 488, 403, 336, 275, 229, 182, 159, 141, 143, 140,
143, 160, 163, 183, 204, 230, 241, 244, 281, 316, 382, 448, 515,
624, 720, 790, 840, 790, 709, 616, 505, 412, 329, 267, 218, 186,
166, 155, 148, 158, 171, 183, 204, 211, 230, 243, 235, 268, 280,
315, 395, 525, 690, 881, 986, 1037, 1002, 930, 790, 668, 556,
444, 335, 276, 236, 218, 201, 201, 216, 227, 257, 290, 331, 368,
401, 451, 525, 599, 693, 823, 988, 1160, 1354, 1466, 1468, 1399,
1220, 1016, 824, 648, 501, 402, 326, 273, 253, 233, 235, 266,
271, 300, 359, 380, 422, 462, 532, 592, 703, 886, 1062, 1253,
1444, 1588, 1701, 1691, 1551, 1372, 1141, 929, 713, 563, 445,
362, 305, 258, 245, 240, 254, 280, 319, 348, 394, 416, 478, 537,
608, 717, 829, 989, 1197, 1426, 1551, 1579, 1563, 1447, 1244,
1026, 801, 638, 500, 379, 303, 265, 230, 221, 202, 203, 225,
246, 289, 303, 327, 374, 396, 462, 539, 625, 744, 899, 1017,
1094, 1138, 1058, 946, 832, 677, 543, 415, 337, 272, 230, 200,
182, 173, 170, 173, 174, 196, 208, 218, 236, 250, 280, 324, 364,
424, 505, 567, 627, 649, 660, 626, 568, 484, 400, 325, 276, 222,
185, 159, 143, 136, 129, 130, 131, 135, 142, 153, 162, 178, 191,
208, 228, 245, 285, 317, 347, 378, 397, 380, 367, 323, 288, 242,
202, 171, 151, 130, 112, 112, 103, 101, 103, 100, 113, 119, 118,
127, 135, 143, 155, 158, 177, 195, 207, 226, 247, 253, 244, 224,
201, 177, 156, 134, 118, 113, 102, 100, 90, 88, 84, 94, 87, 94,
102, 103, 101, 108, 107, 121, 120, 131, 136, 127, 135, 122, 91,
41, 3, 5, 32, 48, 50, 61, 71, 75, 80, 87, 90, 98, 108, 107, 127,
136, 139, 145, 149, 138, 139, 129, 117, 106, 94, 91, 84, 74,
75, 70, 71, 74, 72, 74, 81, 78, 87, 85, 81, 91, 93, 98, 102,
122, 120, 127, 129, 126, 133, 113, 103, 97, 90, 85, 75, 79, 69,
63, 65, 68, 68, 71, 74, 73, 78, 71, 81, 78, 87, 92, 104, 109,
118, 115, 130, 121, 122, 111, 97, 89, 87, 85, 75, 71, 70, 62,
65, 60, 69, 60, 68, 64, 66, 70, 81, 82, 85, 89, 90, 96, 105,
122, 115, 126, 114, 119, 105, 96, 94, 85, 72, 68, 62, 70, 58,
59))
blue.peaks <- tibble(time = data2$time, value = data2$peak)
blue.peaks <- blue.peaks %>% mutate(left_v = c(0.01, diff(value)),
right_v = -lead(left_v, default = -0.01),
is_peak = if_else(left_v > 0 & right_v >= 0, TRUE, FALSE))
data2$keep <- blue.peaks$is_peak
data2$keep <- ifelse(data2$keep == TRUE, data2$peak, NA)
ggplot(data2, aes(x=time, y=peak)) +
geom_col() +
geom_point(aes(x=time, y=keep))
BEFORE EDIT
data (only peak values):
peak <- c(
509, 672 ,758, 686 ,584, 559, 727, 759, 688, 528, 562, 711, 768, 678, 644, 750, 822, 693, 531, 566, 738, 793, 730, 511, 587 ,739, 761, 651, 579,
747, 768, 705, 544, 551, 687, 756, 749, 645, 564, 680, 724, 691, 596, 535, 625, 685, 689, 612, 512, 537, 616, 657, 653 ,573, 506, 598, 675, 685,
668, 609 ,515, 575, 656, 687, 678, 626, 533, 509, 587, 641, 680, 663, 602, 515 ,505, 583, 646, 693, 696, 684, 630, 549, 500 ,572, 637, 681, 725,
736 ,736, 703, 649, 556, 568, 637, 682, 743, 765, 767, 709, 660, 587, 548, 622, 690, 761, 779, 764, 749, 694, 631 ,525 ,571 ,646, 724, 788, 811,
834, 818, 776, 712, 616, 536, 556, 649, 738, 801, 857, 866, 837, 808, 718 ,647 ,568, 508, 605, 714, 823, 872, 917 ,916, 890 ,825, 742, 642, 543,
549, 656, 766, 851, 921, 947, 951, 892, 830, 730, 617, 586, 675, 760, 804, 816 ,795, 740, 690, 613, 522)
code:
peak_data <- tibble(
value = peak
)
peak_data <- peak_data %>%
mutate(
left_v = c(0.01, diff(value)),
right_v = -lead(left_v, default = -0.01),
peak = if_else(
(left_v > 0 & right_v >= 0) | (left_v >= 0 & right_v > 0), TRUE, FALSE
)
) %>%
filter(peak == TRUE) %>%
select(-left_v, -right_v, -peak)
I've put some postive number (0.01) for cheking if edges are peaks. I've got 24 peaks (local max) from this code:
peak_data %>% nrow()
[1] 24
I'm still not exactly sure what you mean by peak, for example vector:
x <- c(5, 6, 6, 4)
has 2 peaks in my code. Its easy to adapt it to have 0 peaks with change:
(left_v > 0 & right_v >= 0) | (left_v >= 0 & right_v > 0)
to:
left_v > 0 & right_v > 0
then I get 22 peaks. Or you can count it as 1 by putting one of:
left_v >= 0 & right_v > 0
left_v > 0 & right_v >= 0
depending what side you want to count for 23 peaks.
AFTER EDIT AND COMMENT
peak_data <- tibble(
peak = peak,
time = time
)
peak_data <- peak_data %>%
mutate(
left_v = c(0.01, diff(peak)),
right_v = -lead(left_v, default = -0.01),
is_peak = if_else(
left_v > 0 & right_v >= 0, TRUE, FALSE
)
) %>%
filter(is_peak == TRUE) %>%
select(peak, time)
gives peaks and peaks time.

Unused argument in GA package

I'm trying to use TSP package with GA. I want to do something similar to this
My code:
library(GA)
library(globalOptTests)
library(TSP)
data("USCA50")
fitFun <-
function(x)
-tour_length(solve_TSP(USCA50))
dist <- as.matrix(USCA50)
GA <- ga(
type = "permutation",
fitness = fitFun,
distMatrix = dist,
min =1,
max = 50
)
The error I get:
Error in fitness(Pop[i, ], ...) :
unused argument (distMatrix = c(0, 1167, 1579, 437, 3575, 1453, 226, 2976, 1107, 1006, 1046, 891, 1488, 1030, 1803, 190, 1122, 1373, 1860, 523, 1047, 1152, 370, 1453, 1629, 1323, 1032, 654, 1462, 752, 993, 813, 1178, 1705, 816, 1206, 1285, 1641, 1578, 1703, 1343, 1317, 1647, 1157, 1479, 1703, 1166, 1211, 795, 1572, 1167, 0, 413, 1422, 2895, 316, 1172, 3094, 140, 382, 189, 530, 392, 526, 635, 1174, 2056, 286, 692, 910, 207, 211, 1035, 303, 2046, 2164, 1385, 845, 297, 597, 1033, 393, 1766, 546, 386, 1076,
153, 476, 432, 546, 184, 184, 481, 1579, 1686, 543, 20, 2008, 527, 434, 1579, 413, 0, 1832, 2766, 167, 1585, 3265, 508, 677, 547, 842, 229, 775, 229, 1575, 2451, 275, 289, 1277, 582, 514, 1420, 207, 2347, 2544, 1720, 1189, 116, 947, 1350, 800, 2117, 138, 777, 1338, 334, 62, 106, 145, 260, 312, 128, 1911, 1961, 136, 413, 2384, 913, 131, 437, 1422, 1832, 0, 3437, 1732, 272, 2607, 1327, 1355, 1345, 1269, 1787, 1409, 2041, 615, 697, 1670, 2093, 954, 1256, 1345, 807, 1672, 1242, 8
Is there something wrong with my GA package? RStudio doesn't show me this parameter but somehow others are able to run it.

Selecting just some rows of a RGList

I am using the package Limma to analyse some data. After reading the raw data with read.maimagenes I get a RGList object. R.cut and G.cut are a value of class numeric and I want the values above them. I tried something like this:
RG$R <- RG$R[RG$R>R.cut]
RG$G <- RG$G[RG$G>G.cut]
But this converts the class of RG$R from matrix to numeric how could I keep the matrix class (I don't know if introducing some NA values would affect the rest of the analyse). I have tried subset like this:
RG.probe$R <- subset(x=RG, subset=RG$R>R.cut)
But it keeps returning an error Error: Two subscripts required
How can this be done?
Aside: If I would like to just get the rows that are above the R.cut and G.cut?
Possible solution:
I have found that with ifelse I can do it although I must introduce a value for the ones that are under the cut, and I haven't found the way to check if both R and G channels are above each cut.
RG$R<-ifelse(RG$R>R.cut, RG$R, '')
RG$G<-ifelse(RG$G>G.cut, RG$G, '')
Although it is converted to character, and therefore I cannot do further analysis.
Data to make it reproducible:
library(limma)
RG<-read.maimages(path, source='agilent')
class(RG)
[1] "RGList"
attr(,"package")
[1] "limma"
dput(head(RG$R))
structure(c(2893, 81.5, 80.5, 140208, 4512, 6272, 4934, 195,
184.5, 164092, 11819, 10569, 1689.5, 83, 82, 68996, 2260.5, 3603,
2470, 84, 77, 96750, 3203, 5223, 3246, 85.5, 104.5, 54773, 519.5,
8244.5, 1807, 86.5, 88, 204574, 15693, 8939.5, 2040, 87, 95,
131880, 7346, 9922.5, 1445, 76, 85.5, 125598, 3863, 5758.5, 2626,
87.5, 85, 180266, 18173, 20171.5, 1811.5, 84, 87.5, 122498, 3993,
5857, 1799, 87.5, 82, 123220, 3780, 5964, 1706, 77.5, 80, 124463,
3390, 5070, 3787, 81.5, 88, 65874, 269, 781.5, 1476, 90, 89,
122445, 4232, 6479, 2788, 82, 87.5, 80669, 791, 7440.5, 1503,
81, 88, 124702, 4270, 6111, 2012.5, 93.5, 90, 215820, 4555, 3101,
1727.5, 102, 109, 131316, 4284, 6638, 2009, 95.5, 111.5, 175474,
12665, 17213, 1532, 87.5, 84.5, 117568, 4098, 6100, 1436, 83,
91, 118472, 4067.5, 6114, 1651.5, 83, 82, 127308, 4150, 6277,
2028.5, 85.5, 89, 74816, 896.5, 7697, 2698, 84, 92.5, 99431,
1273, 9182.5, 1833.5, 100, 104, 163604, 15582, 12146, 2359, 102,
109, 159301, 17229, 9822.5, 1857, 86, 88, 130319, 4354.5, 6266.5,
1887, 87, 87, 133386, 11639.5, 8931, 2304.5, 86.5, 87, 91022,
1011, 14524, 1353, 84, 88, 114282, 3935, 5944, 1487, 83, 87,
125507, 4138, 5804, 3379, 86.5, 88, 63703.5, 331, 1167, 1778,
87, 83.5, 123988, 4366, 6670, 1862, 94.5, 92, 134174, 4558, 6881,
2388.5, 82, 91.5, 174744, 8570, 10677, 4374, 94, 94, 179579,
12753, 10869, 3747.5, 115, 144.5, 133809, 3710, 5406, 5062, 93.5,
92, 207843, 13220, 6774, 3294, 78, 82.5, 149764, 3774, 5582,
5303, 93, 100, 93479.5, 803, 6709, 2969, 86.5, 101, 149011, 4043,
5407, 5488, 106, 118.5, 191053, 9990.5, 12194, 4308, 89, 85,
143087, 3926.5, 5370.5, 5168, 87, 91.5, 137415, 4028, 5671, 4649.5,
91, 90, 147328, 4102, 5614.5, 7225, 87, 85, 179052, 15612, 16908,
5815.5, 84, 88, 200883, 13229, 11482, 3551, 101, 125, 224012,
20461, 16149.5, 3992, 98, 83, 134744, 3569, 5068, 4817, 97, 92,
142087, 4203, 5678, 5436, 108, 84.5, 195104, 11299, 13246), .Dim = c(6L,
51L), .Dimnames = list(NULL, c("US23502326_253482110017_S01_GE2_1105_Oct12_1_1",
"US23502326_253482110017_S01_GE2_1105_Oct12_2_1", "US23502326_253482110017_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110017_S01_GE2_1105_Oct12_2_3", "US23502326_253482110017_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110027_S01_GE2_1105_Oct12_1_1", "US23502326_253482110027_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110027_S01_GE2_1105_Oct12_1_3", "US23502326_253482110027_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110027_S01_GE2_1105_Oct12_2_1", "US23502326_253482110027_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110027_S01_GE2_1105_Oct12_2_3", "US23502326_253482110027_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110028_S01_GE2_1105_Oct12_1_1", "US23502326_253482110028_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110028_S01_GE2_1105_Oct12_1_4", "US23502326_253482110028_S01_GE2_1105_Oct12_2_1",
"US23502326_253482110028_S01_GE2_1105_Oct12_2_2", "US23502326_253482110028_S01_GE2_1105_Oct12_2_3",
"US23502326_253482110029_S01_GE2_1105_Oct12_1_1", "US23502326_253482110029_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110029_S01_GE2_1105_Oct12_1_3", "US23502326_253482110029_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110029_S01_GE2_1105_Oct12_2_1", "US23502326_253482110029_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110029_S01_GE2_1105_Oct12_2_3", "US23502326_253482110029_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110030_S01_GE2_1105_Oct12_1_1", "US23502326_253482110030_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110030_S01_GE2_1105_Oct12_1_3", "US23502326_253482110030_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110030_S01_GE2_1105_Oct12_2_1", "US23502326_253482110030_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110030_S01_GE2_1105_Oct12_2_3", "US23502326_253482110030_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110031_S01_GE2_1105_Oct12_1_1", "US23502326_253482110031_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110031_S01_GE2_1105_Oct12_1_3", "US23502326_253482110031_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110031_S01_GE2_1105_Oct12_2_1", "US23502326_253482110031_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110031_S01_GE2_1105_Oct12_2_3", "US23502326_253482110031_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110049_S01_GE2_1105_Oct12_1_1", "US23502326_253482110049_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110049_S01_GE2_1105_Oct12_1_3", "US23502326_253482110049_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110049_S01_GE2_1105_Oct12_2_1", "US23502326_253482110049_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110049_S01_GE2_1105_Oct12_2_3", "US23502326_253482110049_S01_GE2_1105_Oct12_2_4"
)))
dput(head(RG$G))
structure(c(2324, 58, 52, 98015, 9800, 5284, 1472, 114, 92.5,
27879, 2296, 3272.5, 3637, 216, 204.5, 34898, 731, 5084, 3466,
77, 74, 32543, 497, 7416, 1344, 79.5, 99, 52753, 2363, 3457,
686, 39, 44.5, 32866, 2937, 4324, 910, 42, 40, 42361, 2780, 4072,
1587, 83.5, 97, 79659, 7667, 10103, 754, 49.5, 44, 23664, 2962,
4166, 1390.5, 136, 156.5, 70132.5, 7914, 4876, 1609, 99, 125,
25923.5, 610, 5125, 1526, 198.5, 157, 94640.5, 10408, 9233, 1060,
42, 37, 70033, 3144, 4355.5, 1465, 89, 91, 99188, 9587, 7547,
743, 61.5, 60, 65888, 3247, 4676.5, 1931.5, 89, 84, 65967, 11226,
7757, 873.5, 56, 66, 20126.5, 3291, 4736, 1339.5, 298, 300, 75324,
6712, 8500, 894, 65, 86, 26341.5, 3132.5, 4647, 2372, 80, 81.5,
73418.5, 5026, 7612, 1564, 70, 73, 77180, 7802.5, 9454, 1315,
90, 85, 20562, 340, 5337, 868.5, 49, 55, 64712.5, 2947, 4260,
798, 46, 48, 52505, 3380, 4663.5, 904, 69.5, 80, 33371.5, 3300,
4997, 813, 73, 81, 29552, 2932, 4632.5, 1696.5, 187, 324, 63647,
6407, 8571.5, 872, 39.5, 52, 24518, 3094, 4387, 752.5, 54, 52,
48299.5, 3221, 4278, 2631, 61, 72, 27229, 513, 5019, 1256.5,
61, 63, 74560, 11016, 9019, 942, 57, 55, 70933.5, 3526.5, 5383,
1457.5, 162, 193.5, 86276, 8154, 12084, 1590, 213, 293, 66871,
6580, 9535, 833.5, 57, 62.5, 36416, 3229, 4600, 2161.5, 53.5,
42.5, 39157.5, 2952, 3977, 3481, 67, 68, 18675, 152, 536, 1977,
57, 55.5, 32861, 2785, 3812, 4739.5, 112.5, 113.5, 104923, 6231,
8198, 1907, 57.5, 69, 76674.5, 3219, 4244, 3879.5, 183.5, 171,
110822, 9582, 8426, 1746, 74.5, 74, 33327, 2774, 4017, 3333,
187, 270.5, 83696, 6616, 7080, 4737, 38, 37, 30041, 429.5, 3970,
3347, 45, 46, 106822, 8003.5, 7137.5, 2431, 32, 35, 32985, 3121,
4179, 2535.5, 28, 34, 36131.5, 3135, 4126, 1929, 42, 65, 47428,
3300, 4626.5, 5371, 54.5, 43.5, 108175, 9983, 6182, 5139.5, 34,
28, 26774, 152, 518, 2621, 48, 32, 44499, 3409, 4643), .Dim = c(6L,
51L), .Dimnames = list(NULL, c("US23502326_253482110017_S01_GE2_1105_Oct12_1_1",
"US23502326_253482110017_S01_GE2_1105_Oct12_2_1", "US23502326_253482110017_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110017_S01_GE2_1105_Oct12_2_3", "US23502326_253482110017_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110027_S01_GE2_1105_Oct12_1_1", "US23502326_253482110027_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110027_S01_GE2_1105_Oct12_1_3", "US23502326_253482110027_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110027_S01_GE2_1105_Oct12_2_1", "US23502326_253482110027_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110027_S01_GE2_1105_Oct12_2_3", "US23502326_253482110027_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110028_S01_GE2_1105_Oct12_1_1", "US23502326_253482110028_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110028_S01_GE2_1105_Oct12_1_4", "US23502326_253482110028_S01_GE2_1105_Oct12_2_1",
"US23502326_253482110028_S01_GE2_1105_Oct12_2_2", "US23502326_253482110028_S01_GE2_1105_Oct12_2_3",
"US23502326_253482110029_S01_GE2_1105_Oct12_1_1", "US23502326_253482110029_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110029_S01_GE2_1105_Oct12_1_3", "US23502326_253482110029_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110029_S01_GE2_1105_Oct12_2_1", "US23502326_253482110029_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110029_S01_GE2_1105_Oct12_2_3", "US23502326_253482110029_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110030_S01_GE2_1105_Oct12_1_1", "US23502326_253482110030_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110030_S01_GE2_1105_Oct12_1_3", "US23502326_253482110030_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110030_S01_GE2_1105_Oct12_2_1", "US23502326_253482110030_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110030_S01_GE2_1105_Oct12_2_3", "US23502326_253482110030_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110031_S01_GE2_1105_Oct12_1_1", "US23502326_253482110031_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110031_S01_GE2_1105_Oct12_1_3", "US23502326_253482110031_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110031_S01_GE2_1105_Oct12_2_1", "US23502326_253482110031_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110031_S01_GE2_1105_Oct12_2_3", "US23502326_253482110031_S01_GE2_1105_Oct12_2_4",
"US23502326_253482110049_S01_GE2_1105_Oct12_1_1", "US23502326_253482110049_S01_GE2_1105_Oct12_1_2",
"US23502326_253482110049_S01_GE2_1105_Oct12_1_3", "US23502326_253482110049_S01_GE2_1105_Oct12_1_4",
"US23502326_253482110049_S01_GE2_1105_Oct12_2_1", "US23502326_253482110049_S01_GE2_1105_Oct12_2_2",
"US23502326_253482110049_S01_GE2_1105_Oct12_2_3", "US23502326_253482110049_S01_GE2_1105_Oct12_2_4"
)))
From the dput you can create an RGList by new("RGList") I know it is to much data but as I previously asked I don't know how to short the output.
The solution that finally I got is doing almost the same:
RG$G <- ifelse(RG$R>R.cut, RG$G, NA)
RG$R <- ifelse(RG$G>G.cut, RG$R, NA)
Deleting this values seems to increase the Fold Change of each gene as already happened comparing the original RG with the RG with deleted values as in the question.

Resources