I am trying to smooth a data by rounding the variable "depth" and then apply the function summarize
on the given dataset.
mean_safely <- possibly(.f = mean, otherwise = NA)
SdesGG <- SdesGG %>% filter(., depth > 2) %>%
mutate(depth = round(depth, 0)) %>%
group_by(ctd_file) %>%
summarize(across(temperature:salinity ~ round(list(mean_safely(.)),1))) %>% ungroup()
You will find below the sample :
SdesGG <- structure(list(temperature = c(0.9308, 1.4809, 1.9412, 1.9704,
1.9441, 1.1894, 1.974, 0.455, 1.9655, 1.9502, 1.9506, 0.5185,
1.9474, 1.9922, 2.0393, 0.9345, 0.6809, 1.2231, 1.9733, 1.9751,
1.229, 1.9569, 2.034, 1.9767, 1.3208, 1.0682, 1.9452, 1.9461,
1.8048, 1.1801, 1.9616, 1.9775, 1.9877, 0.8288, 1.9759, 1.9857,
1.9831, 0.5541, 1.9875, 1.9825, 2.0005, 0.8818, 1.3144, 1.8218,
1.2221, 0.5575, 0.8648, 1.9827, 1.7399, 1.9895, 0.5259, 2.0424,
1.9526, 1.9882, 1.1759, 1.9853, 1.9847, 1.0108, 0.6056, 1.998,
0.4447, 1.9707, 1.2876, 1.975, 1.9366, 1.9689, 0.5475, 1.938,
1.9368, 1.9366, 1.9704, 1.1177, 1.9505, 1.3533, 1.813, 1.8302,
1.9477, 1.9355, 1.9688, 1.9349, 1.9364, 1.9729, 1.9724, 2.0328,
1.9761, 1.9465, 1.9744, 1.9367, 0.4231, 1.9361, 1.1732, 1.1402,
0.9043, 0.7205, 0.3785, 0.3929, 0.4127, 0.4346, 0.3992, 1.1883,
1.4211, 0.4132, 0.3572, 0.4144, 1.6264, 0.4566, 0.466, 0.209,
1.3406, 1.9491, 1.0865, 0.9498, 1.9572, 0.836, 1.3802, 1.7071,
0.3476, 1.9985, 1.9547, 1.2505, 0.9536, 1.0958, 0.0347, 0.7404,
1.5834, 2.7523, 1.6212, 0.3825, 0.9406, 0.4867, 0.5643, 1.8807,
0.8969, 1.6772, 1.8589, 0.6775, 0.6807, 0.051, 0.8666, 4.1077,
0.9921, 1.5596, 1.6411, 4.5329, 1.3255, 1.1467, 1.1542, 1.5876,
1.1037, 0.2636, 1.1306, 1.7967, 1.7743, 2.0192, 0.2678, 1.9754,
1.8641, 0.3485, 0.3189, 0.8568, 1.7012, 1.3957, 2.0179, 0.6845,
1.0104, 1.9718, 2.022, 1.9756, 1.9604, 1.958, 0.242, 1.6566,
1.9771, 1.4425, 1.1437, 0.5678, 1.9822, 1.7978, 1.964, 0.313,
1.425, 1.932, 0.4268, 0.8861, 0.6902, 1.9409, 1.9519, 2.0557,
0.6445, 1.9409, 1.9489, 1.9453, 0.9755, 1.9599, 0.8472, 0.0834,
1.6046, 1.9318, 1.9498, 1.9317), fluorescence = c(1.2416, 0.059356,
0.043751, 0.036227, 0.045816, 0.058391, 0.034131, 0.054932, 0.036311,
0.038989, 0.05338, 0.059174, 0.035708, 0.060092, 0.060673, 0.058095,
0.055442, 0.048986, 0.034719, 0.031841, 0.053571, 0.0404, 0.05484,
0.038205, 0.053787, 1.3745, 0.043484, 0.038612, 0.061635, 0.047504,
0.052877, 0.032757, 0.026687, 0.051545, 0.030342, 0.033858, 0.031262,
0.046113, 0.029848, 0.035317, 0.056674, 0.76054, 0.054171, 0.049573,
0.048061, 0.062181, 0.068336, 0.032807, 0.05209, 0.037087, 0.042379,
0.051727, 0.047473, 0.038959, 0.056963, 0.050888, 0.033068, 0.05053,
0.34197, 0.050204, 0.039011, 0.038919, 0.062745, 0.033352, 0.040496,
0.039149, 0.060463, 0.045803, 0.040281, 0.04064, 0.039728, 0.049628,
0.041484, 0.054378, 0.044619, 0.048705, 0.041199, 0.10722, 0.039876,
0.04514, 0.045093, 0.0329, 0.037108, 0.052406, 0.031364, 0.049695,
0.029335, 0.041752, 0.095417, 0.037819, 0.053198, 0.049533, 0.05071,
0.051106, 0.51342, 1.4482, 0.50474, 0.053666, 0.054703, 0.060486,
0.055064, 0.05313, 0.12354, 0.051955, NA, 0.062835, 0.62916,
0.3623, 0.053007, 0.042539, 0.050775, 0.052358, 0.049075, 0.056145,
0.056917, 0.061122, 0.12266, 0.058804, 0.039958, 0.050389, 1.1909,
0.085306, 0.25516, 0.10338, 0.085282, 0.21009, 0.086941, 0.12483,
1.074, 0.12672, 0.11372, 0.081023, 0.093762, 0.07527, 0.066563,
0.56037, 0.57393, 0.201, 0.10016, 0.16318, 0.087019, 0.078642,
0.072709, 0.20222, 0.080648, 0.088892, 0.078775, 0.084689, 0.087081,
0.16937, 0.053087, 0.055444, 0.050884, 0.047286, 1.7016, 0.036868,
0.062344, 0.14358, 0.17529, 0.045806, 0.055564, 0.05658, 0.062737,
0.34175, 0.059237, 0.034714, 0.054471, 0.038374, 0.034411, 0.047332,
0.77096, 0.050224, 0.037368, 0.063016, 0.061832, 0.068767, 0.052314,
0.049284, 0.039258, 0.060133, 0.048861, 0.04979, 0.054226, 0.056378,
0.74172, 0.052244, 0.048553, 0.067182, 0.049219, 0.047817, 0.040588,
0.040217, 0.055254, 0.047947, 0.056354, 0.30906, 0.064546, 0.042934,
0.043631, NA), par = c(1.6974, 5.5346e-05, 0.00013858, 7.3361e-05,
5.1657e-05, 3.0496e-05, 6.3502e-05, 5.335e-05, 5.0685e-05, 0.00012404,
2.361e-05, 2.9159e-05, 1.9192e-05, 6.0756e-05, 1.9105e-05, 5.7069e-05,
9.5946e-05, 8.8133e-05, 0.00010426, 5.3174e-05, 1.4931e-05, 5.2996e-05,
4.9576e-05, 4.5506e-05, 6.0607e-06, 2.209, 6.5072e-05, 3.2411e-05,
9.0745e-05, 9.4845e-06, 0.00011921, 3.5271e-05, -7.72e-07, 1.3421e-05,
2.4226e-05, 7.4273e-05, 2.5845e-05, 0.0001111, 1.3496e-05, 8.7783e-05,
0.00011209, 0.40803, 6.8998e-05, 2.6666e-05, -1.011e-06, 3.9958e-05,
4.2753e-05, 1.9249e-06, 5.8514e-05, 7.0402e-05, 4.3381e-05, 5.5188e-05,
6.29e-06, 3.4205e-06, 8.9512e-06, 3.5569e-05, 0.00010206, 2.4146e-05,
0.042612, 5.2609e-05, 7.0174e-05, 3.5633e-06, 5.5222e-05, 5.7656e-05,
4.2268e-05, 3.6032e-05, 1.8879e-05, 1.4931e-05, 2.795e-05, 2.811e-05,
1.9217e-05, 2.2953e-05, 6.8208e-06, 4.4007e-05, 2.915e-05, 6.1766e-05,
3.4101e-05, 2.0051e-05, 3.657e-05, 0.00011654, 6.2764e-05, 8.3353e-05,
1.2452e-06, 8.0727e-05, 7.9778e-05, 6.7241e-05, 9.0843e-05, 3.5208e-05,
1.5974e-05, 7.7922e-05, 7.4332e-05, 3.867e-05, 3.4518e-05, 4.0664e-05,
3.1511, 13.346, 1.5865, 3.8304e-05, 7.0197e-06, 6.2889e-05, 5.2305e-05,
6.3554e-05, 0.16325, 3.5129e-05, 5.1483e-05, 5.1007e-05, 4.5315,
0.25318, 1.0616e-06, 1.8125e-05, 3.5275e-05, 7.5935e-06, 2.7635e-05,
5.3401e-05, 4.8189e-05, 1.579e-05, 4.4328e-05, 1.9467e-05, 4.2492e-05,
6.6007e-05, 16.809, 2.2957e-05, 1.487e-05, 2.1135e-05, 8.5334e-05,
69.19, 9.4669e-07, 4.8723e-05, 11.806, 2.6083e-05, 1.8565e-06,
3.1858e-05, 4.6153e-05, 3.1247e-05, 8.9936e-05, 1.0418, 1.286,
4.3819e-05, 6.8601e-05, 72.817, 9.5971e-05, 3.8041e-06, 7.507e-05,
68.365, 1.6492e-05, 1.6143e-06, 2.9006e-05, 1.4072e-05, 2.6006e-05,
-6.96e-06, 9.3415e-05, 3.1039e-05, 4.0213e-05, 5.1291e-05, 41.211,
5.8782e-05, -4.023e-07, 0.049406, 0.11159, 2.2583e-06, -1.409e-06,
5.232e-05, 8.0308e-05, 83.871, 2.0754e-05, 1.255e-05, 3.2088e-05,
2.5955e-05, 2.8808e-05, 3.8295e-05, 1.0499, 2.4432e-05, 4.5624e-05,
2.8149e-05, 9.8288e-05, 5.158e-05, 6.4363e-05, 1.2171e-05, -1.655e-07,
6.457e-05, 6.9252e-05, 1.8027e-06, 1.6697e-06, 3.9826e-05, 2.2247,
5.485e-05, 4.2182e-05, 4.1616e-05, 1.6252e-06, 3.247e-05, 5.5941e-05,
2.6743e-05, 2.1318e-05, 3.3666e-05, 2.0362e-05, 0.071072, 5.3865e-05,
4.6206e-05, 3.4668e-06, 2.5886e-05), turbidity = c(0.675, 0.663,
0.407, 0.41, 0.368, 0.562, 0.841, 0.637, 0.371, 0.246, 0.166,
0.438, 0.472, 0.384, 0.419, 0.607, 0.473, 0.706, 0.668, 0.782,
0.533, 0.541, 0.434, 0.418, 0.425, 0.64, 0.343, 0.42, 0.474,
0.66, 0.565, 0.414, 1.502, 2.393, 0.673, 1.425, 0.315, 1.957,
1.335, 1.411, 0.834, 0.597, 0.661, 0.802, 0.596, 1.994, 1.52,
1.277, 0.699, 0.36, 2.873, 0.881, 0.194, 0.453, 0.9, 0.238, 1.54,
0.704, 0.619, 0.461, 0.73, 0.187, 0.425, 0.839, 0.289, 0.301,
0.663, 0.375, 0.404, 0.359, 0.523, 0.678, 0.287, 0.32, 0.46,
0.619, 0.292, 0.277, 0.587, 0.318, 0.239, 0.454, 0.72, 0.475,
0.824, 0.401, 0.82, 0.462, 0.83, 0.37, 0.497, 0.549, 0.611, 0.531,
0.537, 0.45, 0.626, 0.7, 0.714, 0.632, 0.833, 0.636, 0.739, 0.579,
0.574, 0.807, 0.453, 0.582, 0.35, 0.501, 0.563, 0.685, 0.377,
0.472, 0.556, 0.684, 0.763, 0.613, 0.292, 0.635, 0.903, 0.536,
0.364, 0.444, 0.328, 0.419, 0.352, 0.268, 0.826, 0.462, 0.243,
0.467, 0.403, 0.317, 0.458, 0.848, 0.535, 0.1, 0.41, 0.734, 0.29,
0.329, 0.274, 0.495, 0.594, 0.269, 0.473, 0.449, 0.307, 0.281,
0.356, 0.729, 0.553, 0.459, 0.537, 0.593, 0.599, 0.792, 0.734,
0.875, 0.494, 0.509, 0.371, 0.411, 0.621, 0.63, 0.535, 0.65,
0.359, 0.531, 0.262, 0.418, 0.52, 0.395, 0.56, 0.39, 0.342, 0.6,
0.487, 0.542, 0.411, 0.238, 0.605, 0.834, 0.686, 0.488, 0.43,
0.335, 0.687, 0.33, 0.391, 0.473, 0.634, 0.301, 0.999, 0.514,
0.392, 0.175, 0.541, 0.303), conductivity = c(28.23714, 29.910402,
30.622812, 30.706634, 30.616424, 29.52304, 30.792231, 28.484894,
30.698706, 30.597782, 30.596844, 28.666107, 30.667508, 30.595813,
30.592171, 29.1949, 28.867085, 29.58463, 30.7565, 30.773269,
29.594035, 30.686339, 30.593779, 30.743757, 29.70588, 28.355997,
30.612647, 30.6708, 30.320538, 29.510332, 30.507848, 30.684579,
30.821767, 29.046728, 30.713939, 30.805514, 30.691897, 28.376236,
30.820744, 30.834285, 30.552498, 28.273608, 29.703324, 30.350477,
29.579133, 28.381509, 29.089567, 30.77867, 30.245481, 30.704692,
28.576339, 30.604829, 30.590527, 30.708136, 29.517695, 30.58685,
30.798369, 29.295525, 28.177456, 30.591354, 28.430024, 30.726116,
29.642267, 30.779516, 30.607466, 30.725932, 28.71855, 30.593906,
30.606068, 30.627645, 30.724299, 29.421668, 30.664992, 29.750923,
30.335061, 30.35529, 30.657722, 30.638996, 30.737009, 30.636689,
30.624061, 30.708252, 30.757804, 30.595311, 30.787748, 30.656019,
30.775381, 30.605799, 28.566359, 30.640589, 29.489052, 29.441922,
29.126241, 28.881733, 27.855657, 27.704399, 27.971728, 28.487233,
28.519601, 29.500078, 29.840773, 28.513265, 28.134678, 28.512372,
30.104072, 28.392852, 27.898279, 28.002616, 29.718086, 30.597578,
29.372442, 29.192671, 30.589607, 29.033438, 29.781067, 30.203899,
28.261392, 30.582846, 30.591536, 29.58124, 28.300356, 29.324194,
27.902178, 28.90821, 29.927125, 29.235341, 29.975774, 28.512712,
28.298321, 28.641755, 28.713441, 30.329415, 29.096137, 30.046253,
30.30579, 28.182583, 28.16897, 28.056641, 29.061755, 29.525821,
29.203431, 29.895765, 29.998191, 30.27088, 29.598588, 29.384924,
29.391768, 29.93265, 29.336125, 28.365763, 29.420454, 30.285358,
30.257527, 30.596912, 27.177419, 30.751539, 30.369123, 28.145723,
28.080918, 29.057925, 30.170211, 29.796191, 30.595906, 26.871015,
29.265041, 30.763363, 30.556041, 30.752652, 30.682216, 30.587728,
27.801895, 30.105547, 30.737439, 29.847531, 29.442942, 28.717221,
30.587277, 30.303892, 30.690668, 28.433097, 29.785645, 30.611885,
28.443451, 29.088942, 28.127101, 30.59362, 30.708708, 30.58822,
28.761219, 30.646587, 30.686117, 30.671561, 29.213426, 30.579616,
29.040487, 27.906425, 30.077206, 30.598468, 30.702566, 30.598577
), oxygen = c(95.30836, 61.30839, 61.72527, 61.38044, 61.78904,
62.32286, 60.51705, 64.10607, 61.40687, 61.93106, 61.96531, 64.52459,
61.52386, 62.423, 63.13287, 62.46788, 64.01251, 61.82749, 60.78189,
60.71662, 61.92392, 61.37, 63.07995, 61.09333, 61.73046, 98.79564,
61.8274, 61.41733, 61.49582, 62.16286, 61.88601, 61.48436, 60.43031,
63.17072, 61.06652, 60.44985, 61.42799, 64.61788, 60.44033, 60.39656,
62.28728, 90.71317, 61.76414, 61.61359, 61.85428, 64.56538, 63.01494,
60.53314, 61.67233, 61.35219, 63.65403, 62.78311, 61.91755, 61.28692,
62.03254, 62.39467, 60.45186, 62.0126, 81.13226, 62.52332, 64.08187,
61.01156, 62.12969, 60.35834, 61.50232, 60.95488, 63.75405, 61.69758,
61.49532, 61.35196, 61.05137, 62.66967, 61.3375, 61.65203, 61.33197,
61.38335, 61.39052, 61.37645, 60.79641, 61.41601, 61.4266, 61.13603,
60.47735, 62.90927, 60.37454, 61.33937, 60.3574, 61.47752, 63.73667,
61.34602, 62.33298, 62.37765, 63.09669, 63.70941, 87.4317, 100.23521,
81.81966, 63.59, 64.26004, 62.30904, 61.53768, 63.48814, 66.54511,
63.61534, 61.81725, 64.06221, 90.72151, 69.10426, 61.93231, 61.65227,
62.58437, 62.94998, 61.77813, 63.66777, 61.53124, 61.69267, 65.41223,
62.3331, 61.81967, 62.33724, 86.50847, 67.02245, 80.97044, 68.12274,
64.88109, 124.18219, 64.69829, 72.51193, 84.84343, 70.77089,
71.17408, 63.7269, 67.8933, 64.8605, 63.8246, 83.86176, 82.87809,
74.62577, 67.92702, 121.50491, 67.226, 64.98011, 64.69121, 123.97206,
66.24461, 66.8325, 66.90103, 64.88368, 67.01869, 71.05806, 62.572,
61.82355, 61.94597, 62.59414, 124.4799, 60.7162, 62.0682, 66.61708,
66.93478, 63.11839, 61.83074, 61.56426, 62.57315, 130.74507,
62.92445, 60.33282, 62.992, 60.66617, 61.0336, 61.72477, 85.58803,
62.08905, 60.85336, 61.58646, 62.47482, 64.55929, 62.06685, 61.61839,
60.97294, 63.69595, 62.47573, 61.40028, 64.79928, 63.70651, 87.85623,
61.46039, 60.73696, 63.36905, 63.7698, 61.12929, 60.82108, 60.88038,
63.2455, 61.83238, 63.50328, 76.4476, 61.58501, 61.39357, 60.69846,
61.43265), salinity = c(32.913, 34.2816, 34.5177, 34.5274, 34.5171,
34.1559, 34.5287, 33.6995, 34.5278, 34.5133, 34.5131, 33.8467,
34.5229, 34.5011, 34.4719, 34.0474, 33.9205, 34.1837, 34.5286,
34.5287, 34.1885, 34.5258, 34.4772, 34.5288, 34.2193, 32.9212,
34.5163, 34.5234, 34.4093, 34.1522, 34.4542, 34.5279, 34.5284,
33.9886, 34.5286, 34.5282, 34.5302, 33.4671, 34.5284, 34.5284,
34.4636, 33.0078, 34.2216, 34.4188, 34.176, 33.47, 34.0004, 34.5283,
34.3894, 34.5295, 33.7306, 34.4773, 34.512, 34.529, 34.1578,
34.4971, 34.5283, 34.0791, 33.1708, 34.4938, 33.6412, 34.5277,
34.1837, 34.5281, 34.5191, 34.5272, 33.8786, 34.5166, 34.5194,
34.5201, 34.5282, 34.1135, 34.5227, 34.2372, 34.4144, 34.4191,
34.5225, 34.5207, 34.5281, 34.5204, 34.5203, 34.5243, 34.5282,
34.4765, 34.5282, 34.523, 34.5283, 34.5194, 33.822, 34.5207,
34.1397, 34.1203, 33.9948, 33.8982, 33.0025, 32.7963, 33.1138,
33.7185, 33.7916, 34.1368, 34.2664, 33.7709, 33.3755, 33.769,
34.3473, 33.5843, 32.9661, 33.3651, 34.2165, 34.5116, 34.0931,
34.0246, 34.5084, 33.9603, 34.2442, 34.3804, 33.5434, 34.4927,
34.5093, 34.1634, 32.9697, 34.0319, 33.4125, 33.9113, 34.2225,
32.2883, 34.237, 33.8036, 32.9798, 33.8522, 33.8586, 34.3628,
33.9743, 34.2577, 34.3585, 33.1015, 33.0813, 33.5882, 33.9637,
31.3096, 34.0019, 34.211, 34.2414, 31.7699, 34.1155, 34.0516,
34.0507, 34.2247, 34.038, 33.7499, 34.1077, 34.3855, 34.3768,
34.485, 32.2456, 34.5286, 34.411, 33.3979, 33.3478, 33.9673,
34.3541, 34.2463, 34.4849, 31.421, 34.0506, 34.5282, 34.456,
34.5288, 34.526, 34.5093, 33.0756, 34.33, 34.5282, 34.259, 34.1194,
33.856, 34.4993, 34.4042, 34.5269, 33.772, 34.2165, 34.5163,
33.68, 33.9745, 33.0217, 34.5128, 34.5247, 34.4597, 33.8415,
34.5224, 34.524, 34.5235, 34.0252, 34.5041, 33.9592, 33.3707,
34.3403, 34.5142, 34.5245, 34.5142), depth = c(26.5, 333.5, 617,
731, 598, 247, 916, 106, 722, 551.5, 549, 139, 696, 487.5, 440.5,
188.5, 155.5, 271.5, 836, 870.5, 273, 714.5, 445, 800, 293, 24.5,
589, 705, 399.5, 243, 434.5, 666.5, 957, 160, 734.5, 924, 668,
77, 955, 996, 442, 33.5, 295.5, 416.5, 274.5, 77.5, 167, 868.5,
392.5, 685.5, 124, 453, 533, 696.5, 257.5, 488, 909.5, 213, 47,
479.5, 102.5, 774, 277, 886, 589, 778, 147, 560.5, 585, 632.5,
769.5, 231.5, 684.5, 300, 407, 410.5, 674, 659, 801.5, 655.5,
624.5, 735.5, 841.5, 452, 902.5, 671.5, 877.5, 584.5, 137.5,
661.5, 230.5, 222, 183.5, 152, 35, 23.5, 41, 116.5, 130, 231.5,
319.5, 125, 60, 124, 370, 94.5, 32, 57, 287.5, 556, 216.5, 194,
528.5, 165.5, 303.5, 379, 74, 461.5, 536, 247.5, 27, 198, 74,
151, 279, 13, 289.5, 125.5, 29, 135, 138.5, 356, 166, 302.5,
353, 45, 43.5, 91.5, 165, 6.5, 177.5, 275, 293.5, 8, 227.5, 202.5,
205, 279.5, 199, 111.5, 214.5, 379, 375.5, 466.5, 15, 820.5,
390.5, 62.5, 58, 168.5, 362, 304, 467, 9.5, 195.5, 855.5, 422,
822.5, 698, 521, 40.5, 346, 786, 306.5, 219.5, 144.5, 491, 385,
708.5, 131.5, 277, 613, 99.5, 170, 35.5, 561, 777, 422, 124,
662.5, 733, 708, 190.5, 508.5, 162, 64.5, 364.5, 587, 767.5,
587.5), ctd_file = c("BA16001", "BA16001", "BA16001", "BA16001",
"BA16001", "BA16001", "BA16001", "BA16001", "BA16001", "BA16001",
"BA16001", "BA16001", "BA16001", "BA16001", "BA16001", "BA16001",
"BA16001", "BA16001", "BA16001", "BA16001", "BA16001", "BA16001",
"BA16001", "BA16001", "BA16001", "BA16001", "BA16001", "BA16001",
"BA16001", "BA16001", "BA16002", "BA16002", "BA16002", "BA16002",
"BA16002", "BA16002", "BA16002", "BA16002", "BA16002", "BA16002",
"BA16002", "BA16002", "BA16002", "BA16002", "BA16002", "BA16002",
"BA16002", "BA16002", "BA16002", "BA16002", "BA16002", "BA16002",
"BA16002", "BA16002", "BA16002", "BA16002", "BA16002", "BA16002",
"BA16002", "BA16002", "BA16003", "BA16003", "BA16003", "BA16003",
"BA16003", "BA16003", "BA16003", "BA16003", "BA16003", "BA16003",
"BA16003", "BA16003", "BA16003", "BA16003", "BA16003", "BA16003",
"BA16003", "BA16003", "BA16003", "BA16003", "BA16003", "BA16003",
"BA16003", "BA16003", "BA16003", "BA16003", "BA16003", "BA16003",
"BA16003", "BA16003", "BA16004", "BA16004", "BA16004", "BA16004",
"BA16004", "BA16004", "BA16004", "BA16004", "BA16004", "BA16004",
"BA16004", "BA16004", "BA16004", "BA16004", "BA16004", "BA16004",
"BA16004", "BA16004", "BA16004", "BA16004", "BA16004", "BA16004",
"BA16004", "BA16004", "BA16004", "BA16004", "BA16004", "BA16004",
"BA16004", "BA16004", "BA16005", "BA16005", "BA16005", "BA16005",
"BA16005", "BA16005", "BA16005", "BA16005", "BA16005", "BA16005",
"BA16005", "BA16005", "BA16005", "BA16005", "BA16005", "BA16005",
"BA16005", "BA16005", "BA16005", "BA16005", "BA16005", "BA16005",
"BA16005", "BA16005", "BA16005", "BA16005", "BA16005", "BA16005",
"BA16005", "BA16005", "BA16006", "BA16006", "BA16006", "BA16006",
"BA16006", "BA16006", "BA16006", "BA16006", "BA16006", "BA16006",
"BA16006", "BA16006", "BA16006", "BA16006", "BA16006", "BA16006",
"BA16006", "BA16006", "BA16006", "BA16006", "BA16006", "BA16006",
"BA16006", "BA16006", "BA16006", "BA16006", "BA16006", "BA16006",
"BA16006", "BA16006", "BA16007", "BA16007", "BA16007", "BA16007",
"BA16007", "BA16007", "BA16007", "BA16007", "BA16007", "BA16007",
"BA16007", "BA16007", "BA16007", "BA16007", "BA16007", "BA16007",
"BA16007", "BA16007", "BA16007", "BA16007"), Transect = c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), Station = c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L), Lat = c(74.633, 74.633, 74.633, 74.633, 74.633,
74.633, 74.633, 74.633, 74.633, 74.633, 74.633, 74.633, 74.633,
74.633, 74.633, 74.633, 74.633, 74.633, 74.633, 74.633, 74.633,
74.633, 74.633, 74.633, 74.633, 74.633, 74.633, 74.633, 74.633,
74.633, 74.629, 74.629, 74.629, 74.629, 74.629, 74.629, 74.629,
74.629, 74.629, 74.629, 74.629, 74.629, 74.629, 74.629, 74.629,
74.629, 74.629, 74.629, 74.629, 74.629, 74.629, 74.629, 74.629,
74.629, 74.629, 74.629, 74.629, 74.629, 74.629, 74.629, 74.655,
74.655, 74.655, 74.655, 74.655, 74.655, 74.655, 74.655, 74.655,
74.655, 74.655, 74.655, 74.655, 74.655, 74.655, 74.655, 74.655,
74.655, 74.655, 74.655, 74.655, 74.655, 74.655, 74.655, 74.655,
74.655, 74.655, 74.655, 74.655, 74.655, 74.659, 74.659, 74.659,
74.659, 74.659, 74.659, 74.659, 74.659, 74.659, 74.659, 74.659,
74.659, 74.659, 74.659, 74.659, 74.659, 74.659, 74.659, 74.659,
74.659, 74.659, 74.659, 74.659, 74.659, 74.659, 74.659, 74.659,
74.659, 74.659, 74.659, 74.525, 74.525, 74.525, 74.525, 74.525,
74.525, 74.525, 74.525, 74.525, 74.525, 74.525, 74.525, 74.525,
74.525, 74.525, 74.525, 74.525, 74.525, 74.525, 74.525, 74.525,
74.525, 74.525, 74.525, 74.525, 74.525, 74.525, 74.525, 74.525,
74.525, 74.675, 74.675, 74.675, 74.675, 74.675, 74.675, 74.675,
74.675, 74.675, 74.675, 74.675, 74.675, 74.675, 74.675, 74.675,
74.675, 74.675, 74.675, 74.675, 74.675, 74.675, 74.675, 74.675,
74.675, 74.675, 74.675, 74.675, 74.675, 74.675, 74.675, 74.649,
74.649, 74.649, 74.649, 74.649, 74.649, 74.649, 74.649, 74.649,
74.649, 74.649, 74.649, 74.649, 74.649, 74.649, 74.649, 74.649,
74.649, 74.649, 74.649), Long = c(-56.907, -56.907, -56.907,
-56.907, -56.907, -56.907, -56.907, -56.907, -56.907, -56.907,
-56.907, -56.907, -56.907, -56.907, -56.907, -56.907, -56.907,
-56.907, -56.907, -56.907, -56.907, -56.907, -56.907, -56.907,
-56.907, -56.907, -56.907, -56.907, -56.907, -56.907, -56.697,
-56.697, -56.697, -56.697, -56.697, -56.697, -56.697, -56.697,
-56.697, -56.697, -56.697, -56.697, -56.697, -56.697, -56.697,
-56.697, -56.697, -56.697, -56.697, -56.697, -56.697, -56.697,
-56.697, -56.697, -56.697, -56.697, -56.697, -56.697, -56.697,
-56.697, -57.042, -57.042, -57.042, -57.042, -57.042, -57.042,
-57.042, -57.042, -57.042, -57.042, -57.042, -57.042, -57.042,
-57.042, -57.042, -57.042, -57.042, -57.042, -57.042, -57.042,
-57.042, -57.042, -57.042, -57.042, -57.042, -57.042, -57.042,
-57.042, -57.042, -57.042, -57.126, -57.126, -57.126, -57.126,
-57.126, -57.126, -57.126, -57.126, -57.126, -57.126, -57.126,
-57.126, -57.126, -57.126, -57.126, -57.126, -57.126, -57.126,
-57.126, -57.126, -57.126, -57.126, -57.126, -57.126, -57.126,
-57.126, -57.126, -57.126, -57.126, -57.126, -57.253, -57.253,
-57.253, -57.253, -57.253, -57.253, -57.253, -57.253, -57.253,
-57.253, -57.253, -57.253, -57.253, -57.253, -57.253, -57.253,
-57.253, -57.253, -57.253, -57.253, -57.253, -57.253, -57.253,
-57.253, -57.253, -57.253, -57.253, -57.253, -57.253, -57.253,
-57.144, -57.144, -57.144, -57.144, -57.144, -57.144, -57.144,
-57.144, -57.144, -57.144, -57.144, -57.144, -57.144, -57.144,
-57.144, -57.144, -57.144, -57.144, -57.144, -57.144, -57.144,
-57.144, -57.144, -57.144, -57.144, -57.144, -57.144, -57.144,
-57.144, -57.144, -57.399, -57.399, -57.399, -57.399, -57.399,
-57.399, -57.399, -57.399, -57.399, -57.399, -57.399, -57.399,
-57.399, -57.399, -57.399, -57.399, -57.399, -57.399, -57.399,
-57.399)), row.names = c(NA, -200L), class = c("tbl_df", "tbl",
"data.frame"))
CodePudding user response:
round
is expecting a vector
. According to ?round
x - a numeric vector. Or, for round and signif, a complex vector.
By wrapping with list
, it is causing the issue.
library(purrr)
library(dplyr)
SdesGG %>%
filter( depth > 2) %>%
mutate(depth = round(depth, 0)) %>%
group_by(ctd_file) %>%
summarize(across(temperature:salinity ,
~ round(mean_safely(.x, na.rm = TRUE), 1)), .groups= 'drop')
-output
# A tibble: 7 × 8
ctd_file temperature fluorescence par turbidity conductivity oxygen salinity
<chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 BA16001 1.6 0.1 0.1 0.5 30 64.3 34.3
2 BA16002 1.6 0.1 0 1 30 63.5 34.2
3 BA16003 1.7 0 0 0.5 30.3 61.6 34.4
4 BA16004 1 0.2 0.8 0.6 29.1 66.7 33.9
5 BA16005 1.3 0.2 8 0.4 29.2 75.7 33.7
6 BA16006 1.4 0.1 4.2 0.5 29.7 67.5 34.1
7 BA16007 1.5 0.1 0.1 0.5 29.9 64.1 34.2