[R] plotting some rows in different color
Eliza Botto
e||z@_botto @end|ng |rom out|ook@com
Fri Sep 3 00:44:10 CEST 2021
Dear useRs,
For the following dataset,
dput(BFA3)
structure(c(17532, 17533, 17534, 17535, 17536, 17537, 17538,
17539, 17540, 17541, 17542, 17543, 17544, 17545, 17546, 17547,
17548, 17549, 17550, 17551, 17552, 17553, 17554, 17555, 17556,
17557, 17558, 17559, 17560, 17561, 17562, 17563, 17564, 17565,
17566, 17567, 17568, 17569, 17570, 17571, 17572, 17573, 17574,
17575, 17576, 17577, 17578, 17579, 17580, 17581, 17582, 17583,
17584, 17585, 17586, 17587, 17588, 17589, 17590, 17591, 17592,
17593, 17594, 17595, 17596, 17597, 17598, 17599, 17600, 17601,
17602, 17603, 17604, 17605, 17606, 17607, 17608, 17609, 17610,
17611, 17612, 17613, 17614, 17615, 17616, 17617, 17618, 17619,
17620, 17621, 17622, 17623, 17624, 17625, 17626, 17627, 17628,
17629, 17630, 17631, 17632, 17633, 17634, 17635, 17636, 17637,
17638, 17639, 17640, 17641, 17642, 17643, 17644, 17645, 17646,
17647, 17648, 17649, 17650, 17651, 17652, 17653, 17654, 17655,
17656, 17657, 17658, 17659, 17660, 17661, 17662, 17663, 17664,
17665, 17666, 17667, 17668, 17669, 17670, 17671, 17672, 17673,
17674, 17675, 17676, 17677, 17678, 17679, 17680, 17681, 17682,
17683, 17684, 17685, 17686, 17687, 17688, 17689, 17690, 17691,
17692, 17693, 17694, 17695, 17696, 17697, 17698, 17699, 17700,
17701, 17702, 17703, 17704, 17705, 17706, 17707, 17708, 17709,
17710, 17711, 17712, 17713, 17714, 17715, 17716, 17717, 17718,
17719, 17720, 17721, 17722, 17723, 17724, 17725, 17726, 17727,
17728, 17729, 17730, 17731, 17732, 17733, 17734, 17735, 17736,
17737, 17738, 17739, 17740, 17741, 17742, 17743, 17744, 17745,
17746, 17747, 17748, 17749, 17750, 17751, 17752, 17753, 17754,
17755, 17756, 17757, 17758, 17759, 17760, 17761, 17762, 17763,
17764, 17765, 17766, 17767, 17768, 17769, 17770, 17771, 17772,
17773, 17774, 17775, 17776, 17777, 17778, 17779, 17780, 17781,
17782, 17783, 17784, 17785, 17786, 17787, 17788, 17789, 17790,
17791, 17792, 17793, 17794, 17795, 17796, 17797, 17798, 17799,
17800, 17801, 17802, 17803, 17804, 17805, 17806, 17807, 17808,
17809, 17810, 17811, 17812, 17813, 17814, 17815, 17816, 17817,
17818, 17819, 17820, 17821, 17822, 17823, 17824, 17825, 17826,
17827, 17828, 17829, 17830, 17831, 17832, 17833, 17834, 17835,
17836, 17837, 17838, 17839, 17840, 17841, 17842, 17843, 17844,
17845, 17846, 17847, 17848, 17849, 17850, 17851, 17852, 17853,
17854, 17855, 17856, 17857, 17858, 17859, 17860, 17861, 17862,
17863, 17864, 17865, 17866, 17867, 17868, 17869, 17870, 17871,
17872, 17873, 17874, 17875, 17876, 17877, 17878, 17879, 17880,
17881, 17882, 17883, 17884, 17885, 17886, 17887, 17888, 17889,
17890, 17891, 17892, 17893, 17894, 17895, 17896, 8.36875, 15.12875,
14.2825, 12.355, 13.1825, 88.58375, 47.52125, 26.53375, 22.85875,
12.4925, 9.86875, 13.125, 14.055, 14.0175, 14.70625, 15.46125,
11.8725, 17.505, 19.8575, 74.875445, 62.018935, 23.9481046910236,
9.68, 9.6175, 9.78, 9.8875, 9.5125, 9.885, 9.99, 14.16625, 11.99375,
10.7875, 9.85625, 12.17125, 11.76625, 11.0425, 9.28875, 9.425,
23.29375, 12.66875, 9.6, 10.06875, 10.055, 30.89625, 36.69375,
16.63875, 11.84625, 12.825, 14.94, 11.495, 10.795, 9.14625, 10.17875,
11.0525, 10.0175, 10.67625, 10.4325, 12.5175, 13.93, 14.1675,
17.3175, 18.3875, 12.06, 10.3125, 9.94125, 10.8575, 11.2425,
13.28875, 43.885, 76.225, 125.277272727273, 198.285, 181.40125,
113.38875, 89.7925, 108.27875, 100.24375, 103.57, 189.015, 190.8925,
113.76875, 109.055, 96.4925, 99.04625, 127.47125, 300.86, 250.0725,
108.72125, 54.61, 39.76625, 30.11875, 31.46875, 40.73, 40.63,
27.48125, 24.9125, 24.105, 53.65625, 209.77125, 281.53125, 460.90875,
296.4225, 349.58375, 494.825, 404.4475, 510.68125, 681.65625,
637.78125, 838.40125, 740.0875, 601.81375, 246.75625, 127.1725,
92.36875, 78.11875, 73.61625, 62.77875, 59.87, 106.36, 115.31125,
64.025, 96.30125, 97.50625, 92.875, 92.49875, 89.295, 84.46375,
80.05625, 80.745, 114.13, 91.3225, 79.72125, 70.555, 30.8975,
14.28625, 13.02875, 93.59125, 246.7875, 54.37125, 29.45375, 16.2725,
15.175, 15.1475, 16.27875, 15.0575, 14.0425, 11.675, 12.9275,
11.26, 12.56, 183.555, 413.2025, 111.46375, 43.01375, 27.66125,
17.55875, 15.28, 14.88875, 14.60875, 14.44625, 281.95125, 85.16875,
24.6675, 14.88875, 15.02, 23.35125, 65.385, 83.95, 37.675, 22.31375,
15.1075, 15.02625, 96.39, 1856.72375, 612.275, 97.04875, 46.065,
28.62125, 23.22875, 234.78375, 58.21375, 33.29, 55.595, 66.57375,
81.39875, 42.84625, 26.945, 20.00375, 14.26875, 14.87625, 82.975,
85.12125, 35.7575, 26.875, 40.36375, 28.63875, 15.68, 13.70125,
29.42625, 51.81125, 26.6125, 15.56375, 13.725, 191.72625, 376.08625,
66.27875, 72.0275, 47.50375, 26.555, 16.58625, 16.9275, 15.26875,
33.3125, 64.98625, 66.93875, 194.75875, 65.15, 29.03375, 15.545,
14.83625, 14.89, 15.08875, 14.71, 146.1525, 112.855, 34.10625,
16.46625, 15.0175, 15.06125, 13.94625, 12.1075, 14.265, 14.30125,
13.77125, 12.51, 181.65625, 82.07875, 59.46125, 209.9875, 42.5525,
22.19, 32.95, 19.89875, 37.7175, 29.62875, 41.705, 34.1225, 23.7275,
20.565, 17.61125, 16.53125, 15.75125, 119.1025, 79.8675, 27.6375,
15.6675, 13.955, 16.54875, 24.2075, 21.97875, 17.3525, 19.9875,
18.2275, 109.57875, 73.06625, 47.2775, 50.1475, 28.66875, 17.8,
373.38375, 96.49875, 62.55125, 24.56375, 26.7675, 109.57375,
265.26125, 161.6575, 86.80375, 67.98, 62.88125, 64.88625, 97.665,
77.29125, 52.015, 81.7925, 75.305, 45.81875, 39.425, 37.78625,
35.40125, 32.1275, 31.89875, 31.77125, 30.1575, 28.62875, 28.065,
29.6875, 28.47125, 25.525, 25.2125, 22.68125, 22.81625, 20.165,
18.03125, 18.0425, 18.945, 19.88125, 24.6225, 25.6025, 24.65125,
31.76375, 27.41375, 22.8075, 28.64, 25.06875, 26.36125, 29.74625,
23.1, 19.67, 30.01625, 27.285, 43.90125, 50.1425, 33.45375, 23.2225,
19.91625, 27.22875, 46.14125, 33.70375, 38.7525, 178.45625, 85.08,
37.93875, 22.4225, 23.45125, 34.1375, 22.3325, 18.7125, 17.5375,
16.07625, 15.07375, 15.035, 15.16875, 15.6225, 15.9125, 15.3325,
15.09, 14.91125, 14.94125, 14.8325, 14.86375, 14.9675, 14.895,
14.81, 14.77125, 13.66625, 13.135, 13.00875, 12.86375, 12.9525,
13.0675, 12.97, 13.02, 13.10375, 12.96, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 9.86875, 9.84942307692308, 9.83009615384615,
9.81076923076923, 9.79144230769231, 9.77211538461539, 9.75278846153846,
9.73346153846154, 9.71413461538462, 9.69480769230769, 9.67548076923077,
9.65615384615385, 9.63682692307692, 9.6175, 9.5825, 9.5475, 9.5125,
9.56979166666667, 9.62708333333333, 9.684375, 9.74166666666667,
9.79895833333333, 9.85625, 9.714375, 9.5725, 9.430625, 9.28875,
9.3665625, 9.444375, 9.5221875, 9.6, 9.55875, 9.5175, 9.47625,
9.435, 9.39375, 9.3525, 9.31125, 9.27, 9.22875, 9.1875, 9.14625,
9.20740384615385, 9.26855769230769, 9.32971153846154, 9.39086538461538,
9.45201923076923, 9.51317307692308, 9.57432692307692, 9.63548076923077,
9.69663461538462, 9.75778846153846, 9.81894230769231, 9.88009615384615,
9.94125, 10.8575, 11.2425, 11.7121774193548, 12.1395161290323,
12.5668548387097, 12.9941935483871, 13.4215322580645, 13.8488709677419,
14.2762096774194, 14.7035483870968, 15.1308870967742, 15.5582258064516,
15.985564516129, 16.4129032258065, 16.8402419354839, 17.2675806451613,
17.6949193548387, 18.1222580645161, 18.5495967741935, 18.976935483871,
19.4042741935484, 19.8316129032258, 20.2589516129032, 20.6862903225806,
21.1136290322581, 21.5409677419355, 21.9683064516129, 22.3956451612903,
22.8229838709677, 23.2503225806452, 23.6776612903226, 24.105,
25.8080952380952, 27.5111904761905, 29.2142857142857, 30.917380952381,
32.6204761904762, 34.3235714285714, 36.0266666666667, 37.7297619047619,
39.4328571428571, 41.1359523809524, 42.8390476190476, 44.5421428571429,
46.2452380952381, 47.9483333333333, 49.6514285714286, 51.3545238095238,
53.057619047619, 54.7607142857143, 56.4638095238095, 58.1669047619048,
59.87, 61.255, 62.64, 64.025, 60.4722321428572, 56.9194642857143,
53.3666964285714, 49.8139285714286, 46.2611607142857, 42.7083928571429,
39.155625, 35.6028571428571, 32.0500892857143, 28.4973214285714,
24.9445535714286, 21.3917857142857, 17.8390178571429, 14.28625,
13.02875, 12.8926923076923, 12.7566346153846, 12.6205769230769,
12.4845192307692, 12.3484615384615, 12.2124038461538, 12.0763461538462,
11.9402884615385, 11.8042307692308, 11.6681730769231, 11.5321153846154,
11.3960576923077, 11.26, 11.5496590909091, 11.8393181818182,
12.1289772727273, 12.4186363636364, 12.7082954545455, 12.9979545454545,
13.2876136363636, 13.5772727272727, 13.8669318181818, 14.1565909090909,
14.44625, 14.556875, 14.6675, 14.778125, 14.88875, 14.9059375,
14.923125, 14.9403125, 14.9575, 14.9746875, 14.991875, 15.0090625,
15.02625, 14.9816911764706, 14.9371323529412, 14.8925735294118,
14.8480147058824, 14.8034558823529, 14.7588970588235, 14.7143382352941,
14.6697794117647, 14.6252205882353, 14.5806617647059, 14.5361029411765,
14.4915441176471, 14.4469852941176, 14.4024264705882, 14.3578676470588,
14.3133088235294, 14.26875, 14.2056944444444, 14.1426388888889,
14.0795833333333, 14.0165277777778, 13.9534722222222, 13.8904166666667,
13.8273611111111, 13.7643055555556, 13.70125, 13.706, 13.71075,
13.7155, 13.72025, 13.725, 13.8965277777778, 14.0680555555556,
14.2395833333333, 14.4111111111111, 14.5826388888889, 14.7541666666667,
14.9256944444444, 15.0972222222222, 15.26875, 15.2146875, 15.160625,
15.1065625, 15.0525, 14.9984375, 14.944375, 14.8903125, 14.83625,
14.7941666666667, 14.7520833333333, 14.71, 14.3846875, 14.059375,
13.7340625, 13.40875, 13.0834375, 12.758125, 12.4328125, 12.1075,
12.1785576923077, 12.2496153846154, 12.3206730769231, 12.3917307692308,
12.4627884615385, 12.5338461538462, 12.6049038461538, 12.6759615384615,
12.7470192307692, 12.8180769230769, 12.8891346153846, 12.9601923076923,
13.03125, 13.1023076923077, 13.1733653846154, 13.2444230769231,
13.3154807692308, 13.3865384615385, 13.4575961538462, 13.5286538461538,
13.5997115384615, 13.6707692307692, 13.7418269230769, 13.8128846153846,
13.8839423076923, 13.955, 14.2754166666667, 14.5958333333333,
14.91625, 15.2366666666667, 15.5570833333333, 15.8775, 16.1979166666667,
16.5183333333333, 16.83875, 17.1591666666667, 17.4795833333333,
17.8, 17.8066071428571, 17.8132142857143, 17.8198214285714, 17.8264285714286,
17.8330357142857, 17.8396428571429, 17.84625, 17.8528571428571,
17.8594642857143, 17.8660714285714, 17.8726785714286, 17.8792857142857,
17.8858928571429, 17.8925, 17.8991071428571, 17.9057142857143,
17.9123214285714, 17.9189285714286, 17.9255357142857, 17.9321428571429,
17.93875, 17.9453571428571, 17.9519642857143, 17.9585714285714,
17.9651785714286, 17.9717857142857, 17.9783928571429, 17.985,
17.9916071428571, 17.9982142857143, 18.0048214285714, 18.0114285714286,
18.0180357142857, 18.0246428571429, 18.03125, 18.0425, 18.945,
19.0007692307692, 19.0565384615385, 19.1123076923077, 19.1680769230769,
19.2238461538462, 19.2796153846154, 19.3353846153846, 19.3911538461538,
19.4469230769231, 19.5026923076923, 19.5584615384615, 19.6142307692308,
19.67, 19.7051785714286, 19.7403571428571, 19.7755357142857,
19.8107142857143, 19.8458928571429, 19.8810714285714, 19.91625,
19.6419642857143, 19.3676785714286, 19.0933928571429, 18.8191071428571,
18.5448214285714, 18.2705357142857, 17.99625, 17.7219642857143,
17.4476785714286, 17.1733928571429, 16.8991071428571, 16.6248214285714,
16.3505357142857, 16.07625, 15.07375, 15.035, 15.0096875, 14.984375,
14.9590625, 14.93375, 14.9084375, 14.883125, 14.8578125, 14.8325,
14.61375, 14.395, 14.17625, 13.9575, 13.73875, 13.52, 13.135,
13.00875, 12.86375, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, 2, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2, 4, NA,
3, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2,
NA, NA, NA, NA, NA, NA, 1, 4, NA, NA, NA, NA, NA, NA, 2, NA,
NA, NA, NA, NA, 4, 9, NA, NA, NA, NA, 16, NA, NA, NA, NA, NA,
18, 12, 22, 22, 40, NA, NA, NA, NA, 19.5, 14, 17, NA, NA, NA,
NA, 21, 6, 11, NA, NA, NA, 8, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, 11, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 5, 10, 6, NA, NA, NA, NA, NA, NA, NA, 4, 2, NA, NA,
9, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 8, NA,
NA, 8, 1, NA, NA, NA, NA, NA, NA, NA, NA, 2, 4, 5, NA, 6, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 6, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 2, NA, 2, 5, 12, NA, NA, NA, NA,
NA, NA, NA, NA, NA, 19, 13, 19, 23, NA, NA, NA, NA, NA, NA, NA,
19, NA, NA, NA, NA, 17, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, 9, NA, NA, NA, 8, 4, 9, NA, NA, NA, NA, NA, NA, NA, NA, 3,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA), .Dim = c(365L, 4L), .Dimnames = list(
c("17532", "17533", "17534", "17535", "17536", "17537", "17538",
"17539", "17540", "17541", "17542", "17543", "17544", "17545",
"17546", "17547", "17548", "17549", "17550", "17551", "17552",
"17553", "17554", "17555", "17556", "17557", "17558", "17559",
"17560", "17561", "17562", "17563", "17564", "17565", "17566",
"17567", "17568", "17569", "17570", "17571", "17572", "17573",
"17574", "17575", "17576", "17577", "17578", "17579", "17580",
"17581", "17582", "17583", "17584", "17585", "17586", "17587",
"17588", "17589", "17590", "17591", "17592", "17593", "17594",
"17595", "17596", "17597", "17598", "17599", "17600", "17601",
"17602", "17603", "17604", "17605", "17606", "17607", "17608",
"17609", "17610", "17611", "17612", "17613", "17614", "17615",
"17616", "17617", "17618", "17619", "17620", "17621", "17622",
"17623", "17624", "17625", "17626", "17627", "17628", "17629",
"17630", "17631", "17632", "17633", "17634", "17635", "17636",
"17637", "17638", "17639", "17640", "17641", "17642", "17643",
"17644", "17645", "17646", "17647", "17648", "17649", "17650",
"17651", "17652", "17653", "17654", "17655", "17656", "17657",
"17658", "17659", "17660", "17661", "17662", "17663", "17664",
"17665", "17666", "17667", "17668", "17669", "17670", "17671",
"17672", "17673", "17674", "17675", "17676", "17677", "17678",
"17679", "17680", "17681", "17682", "17683", "17684", "17685",
"17686", "17687", "17688", "17689", "17690", "17691", "17692",
"17693", "17694", "17695", "17696", "17697", "17698", "17699",
"17700", "17701", "17702", "17703", "17704", "17705", "17706",
"17707", "17708", "17709", "17710", "17711", "17712", "17713",
"17714", "17715", "17716", "17717", "17718", "17719", "17720",
"17721", "17722", "17723", "17724", "17725", "17726", "17727",
"17728", "17729", "17730", "17731", "17732", "17733", "17734",
"17735", "17736", "17737", "17738", "17739", "17740", "17741",
"17742", "17743", "17744", "17745", "17746", "17747", "17748",
"17749", "17750", "17751", "17752", "17753", "17754", "17755",
"17756", "17757", "17758", "17759", "17760", "17761", "17762",
"17763", "17764", "17765", "17766", "17767", "17768", "17769",
"17770", "17771", "17772", "17773", "17774", "17775", "17776",
"17777", "17778", "17779", "17780", "17781", "17782", "17783",
"17784", "17785", "17786", "17787", "17788", "17789", "17790",
"17791", "17792", "17793", "17794", "17795", "17796", "17797",
"17798", "17799", "17800", "17801", "17802", "17803", "17804",
"17805", "17806", "17807", "17808", "17809", "17810", "17811",
"17812", "17813", "17814", "17815", "17816", "17817", "17818",
"17819", "17820", "17821", "17822", "17823", "17824", "17825",
"17826", "17827", "17828", "17829", "17830", "17831", "17832",
"17833", "17834", "17835", "17836", "17837", "17838", "17839",
"17840", "17841", "17842", "17843", "17844", "17845", "17846",
"17847", "17848", "17849", "17850", "17851", "17852", "17853",
"17854", "17855", "17856", "17857", "17858", "17859", "17860",
"17861", "17862", "17863", "17864", "17865", "17866", "17867",
"17868", "17869", "17870", "17871", "17872", "17873", "17874",
"17875", "17876", "17877", "17878", "17879", "17880", "17881",
"17882", "17883", "17884", "17885", "17886", "17887", "17888",
"17889", "17890", "17891", "17892", "17893", "17894", "17895",
"17896"), c("DAT", "Q", "BF", "")))
The following command gives the values of 1st column for which the values in 2nd and 3rd columns are similar
val<-BFA3[,1][which(BFA3[,2]-BFA3[,3]==0)]
dput(val)
c(`17542` = 17542, `17555` = 17555, `17558` = 17558, `17564` = 17564,
`17568` = 17568, `17572` = 17572, `17583` = 17583, `17596` = 17596,
`17597` = 17597, `17598` = 17598, `17628` = 17628, `17649` = 17649,
`17652` = 17652, `17666` = 17666, `17667` = 17667, `17680` = 17680,
`17691` = 17691, `17695` = 17695, `17703` = 17703, `17720` = 17720,
`17729` = 17729, `17734` = 17734, `17743` = 17743, `17751` = 17751,
`17754` = 17754, `17762` = 17762, `17788` = 17788, `17800` = 17800,
`17835` = 17835, `17836` = 17836, `17837` = 17837, `17850` = 17850,
`17857` = 17857, `17871` = 17871, `17872` = 17872, `17873` = 17873,
`17881` = 17881, `17888` = 17888, `17889` = 17889, `17890` = 17890
)
Now for these values of "val" I want the values of 4th column to be plotted in "green" while all other in "red". I have tried the following command but to no avail
plot(as.numeric(as.Date(BFA3[,1])), BFA3[,4], pch=16, xlab = "", ylab = "",col= ifelse(BFA3[,1]==BFA3[,1][which(BFA3[,2]-BFA3[,3]==0)], "green","red"),axes=F)
Is there a way around it?
I thankyou in advance
[[alternative HTML version deleted]]
More information about the R-help
mailing list