Even if I make the extra effort of reading the sample data from what you have posted into a copy/paste friendly version, your problem is not reproducible with the information you are providing, see this reproducible example:
library(dplyr)
library(lubridate)
# Sample data on a copy/paste friendly format
sample_data <- data.frame(
stringsAsFactors = FALSE,
date = c("04-01-2020 0:00",
"04-01-2020 1:00","04-01-2020 2:00","04-01-2020 3:00",
"04-01-2020 4:00","04-01-2020 5:00","04-01-2020 6:00",
"04-01-2020 7:00","04-01-2020 8:00","04-01-2020 9:00",
"04-01-2020 10:00","04-01-2020 11:00","04-01-2020 12:00",
"04-01-2020 13:00","04-01-2020 14:00","04-01-2020 15:00",
"04-01-2020 16:00","04-01-2020 17:00","04-01-2020 18:00",
"04-01-2020 19:00","04-01-2020 20:00","04-01-2020 21:00",
"04-01-2020 22:00","04-01-2020 23:00","04-02-2020 0:00",
"04-02-2020 1:00","04-02-2020 2:00","04-02-2020 3:00",
"04-02-2020 4:00","04-02-2020 5:00","04-02-2020 6:00",
"04-02-2020 7:00","04-02-2020 8:00","04-02-2020 9:00",
"04-02-2020 10:00","04-02-2020 11:00",
"04-02-2020 12:00","04-02-2020 13:00","04-02-2020 14:00",
"04-02-2020 15:00","04-02-2020 16:00","04-02-2020 17:00",
"04-02-2020 18:00","04-02-2020 19:00","04-02-2020 20:00",
"04-02-2020 21:00","04-02-2020 22:00","04-02-2020 23:00",
"04-03-2020 0:00","04-03-2020 1:00","04-03-2020 2:00",
"04-03-2020 3:00","04-03-2020 4:00","04-03-2020 5:00",
"04-03-2020 6:00","04-03-2020 7:00","04-03-2020 8:00",
"04-03-2020 9:00","04-03-2020 10:00","04-03-2020 11:00",
"04-03-2020 12:00","04-03-2020 13:00","04-03-2020 14:00",
"04-03-2020 15:00","04-03-2020 16:00",
"04-03-2020 17:00","04-03-2020 18:00","04-03-2020 19:00",
"04-03-2020 20:00","04-03-2020 21:00","04-03-2020 22:00",
"04-03-2020 23:00"),
pm2.5 = c(119.5,104.5,99.5,99.5,108.5,
121.75,118.5,115,119.75,87.25,56.25,57.5,45.25,
31.75,36.25,41.75,39.75,50,66.75,95.25,156.5,
128.75,117.25,96.75,77.5,75.25,72,67.25,59.75,56.75,
73,92.75,105.5,98.25,80.25,48.75,47,58.5,44.5,
35.5,40.5,46.75,59.75,56.5,58.5,60.75,68.25,88.25,
99.5,88.75,69.75,65.25,55,57.25,53.25,48.5,48.75,
44.25,41.5,38.25,30.75,24.75,26.25,23.75,21.5,
18.75,25.75,33.5,47.25,72.5,89.5,78),
no = c(33.25,33.42,35.95,41.32,
47.08,46.1,41.9,30.2,17.9,9.17,9.53,8.75,4.1,8.57,
8.03,6.62,6.78,7.55,8.03,11.4,18.35,20.85,20.65,
23.12,25.88,28,29.18,29.3,28.17,29.07,26.68,22.83,
14.85,10.23,8.22,9.6,12.65,7.6,7.82,9.02,9.38,
18.12,14,3.1,5.28,13.38,15.8,14.85,13.92,13.77,
11.95,11.6,16.07,12.78,7.7,13.22,7.9,11.18,8.85,
10.58,3.4,9.4,6.9,7.77,7.72,9.03,9.3,9.9,15.72,
16.18,18.23,18.05),
no2 = c(140.22,142.25,138.93,145.05,
137.52,133.05,134.78,139.35,143.6,146.75,142.52,
139.95,128.97,127.55,130.25,133.5,138.9,139.95,
125.35,95.42,128.02,137.4,138.53,133,136.05,134.47,
132.15,132.12,122.27,124.47,127.07,130.3,132.4,
133.22,124.78,130.5,138.97,136.68,135,132.7,91.1,44.33,
61.97,105.35,115.9,126.2,130.38,132.95,134.08,
136.05,133.15,132.95,133.38,126.78,127.05,128.55,
134.62,133.2,137.18,132.65,125.78,125.7,129.1,129.57,
131.5,137.15,139.78,147.22,157.35,150.07,150.77,
151.5),
nox = c(101.62,102.83,103.12,110.72,
111.45,108.25,105.75,98.67,90.95,85.53,83.53,
81.55,71,74.83,75.8,76.38,79.38,80.57,73.17,60.05,
83.03,90.03,90.5,89.58,93.38,94.25,93.98,94.12,
87.95,89.88,89.3,87.88,82.5,79.17,73.05,77.22,84.2,
78.88,78.2,77.93,56.08,38.33,34.6,56.97,65.92,
78.02,82.2,82.78,82.6,83.55,80.53,80.12,83.97,77.85,
73.82,79.12,78.05,79.95,80.15,79.12,69.65,74.5,
74.3,75.25,76.25,80.28,81.92,86.35,96.47,93.03,95,
95.28),
so2 = c(13.45,12.47,14.38,16.02,
17.2,17.15,15,15.07,16.15,16.33,15.52,14.48,14.32,
14.02,14.7,15.18,13.62,12.6,13.12,14.2,14.12,14.62,
14.85,14.32,17.02,18.8,18.93,18.15,17.8,16.05,
17.62,17.07,15.88,15.97,12.7,10.45,15.1,16.93,
15.55,14.38,15.57,15.38,14.57,15.52,17.33,18.05,13.1,
11.22,13.22,13.7,12.72,11.43,15.68,18.15,17.35,
16.75,18.05,17.38,15.93,15.15,14.43,14.3,12.5,
12.93,11.72,12.27,14.85,17.02,17.58,17,14.15,12.65),
co = c(1.99,1.9,1.87,1.7,2.14,
2.17,2.35,2.41,2.29,2.17,2.17,1.93,1.06,0.95,0.9,
0.9,0.9,1.02,1.12,1.77,2.19,2.29,2.19,1.99,1.72,
1.71,1.64,1.56,1.46,1.44,1.62,1.66,1.55,1.48,
1.23,1.07,1.75,2.02,2.05,2.04,2.1,1.82,2.07,2.07,
1.26,1.5,1.63,1.6,1.31,1.61,1.61,1.33,1.63,2.12,
2.15,2.19,2.17,2.15,2.1,2.03,1.36,1.23,1.2,1.19,
1.21,1.39,1.51,1.82,1.8,2.54,2.36,2.18),
o3 = c(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),
benzene = c(0.47,0.53,0.5,0.53,1.42,
2.05,1.8,1.67,1.52,1.2,1.05,0.83,0.5,0.28,0.23,
0.2,0.28,0.3,0.28,0.53,1.38,1.68,1.55,1.22,1.17,
1.23,1.2,1.05,0.62,0.38,0.35,0.35,0.4,0.43,0.35,
0.3,0.38,0.55,0.47,0.38,0.38,0.5,1.2,1.48,0.93,
0.35,0.32,0.23,0.3,0.3,0.2,0.23,0.35,0.88,0.8,
0.8,0.72,0.65,0.57,0.47,0.35,0.08,0,0,0,0,0,
0.15,0.25,0.95,1.02,0.78),
toulene = c(0.78,0.65,0.7,0.6,1.97,
3.15,1.95,1.85,1.88,1.23,1.3,0.93,0.53,0,0,0,0,0,
0.25,0.6,1.53,1.88,1.9,1.57,1.67,1.8,1.8,1.52,
0.92,0.55,0.55,0.35,0.47,0.47,0,0,0.32,0.88,
0.83,0.47,0.42,0.6,1.8,2.17,1.18,0.28,0,0,0,0,0,
0,0.17,0.93,0.95,0.95,1.02,0.88,0.7,0.83,0.65,
0,0,0,0,0,0,0,0.25,1.18,1,0.83),
Temp = c(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),
rh = c(87,87.5,88.75,89.25,89.5,
90,88.5,84.5,79.75,77.5,75.5,75,74,73,73,73,
73.5,75.5,78,80,81.5,82.75,83.25,84,85,85.75,86,
87,87,87,86.5,83.5,79.25,77.5,74.75,72.25,72,72,
72,72.25,73.5,75.5,77.75,79.5,81,82,82,83,
83.25,84,85,86,87,87,85.5,82.5,79.75,77.5,76.5,
75.25,75,74.25,74.5,75,75.25,77.5,80,81.5,82.25,84,
85,85),
ws = c(0.3,0.3,0.3,0.3,0.3,0.3,
0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,
0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,
0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,
0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,
0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,
0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3),
wd = c(302,261.75,288,172,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,267.5,305.75,246,NA,NA,326,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,280,264,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,355,NA),
sr = c(6,6,6,6,6,6,16.75,51.5,
93.25,131.5,160.5,179,181.5,161.75,136.75,94.25,
48.25,12.5,6,6,6,6,6,6,6,6,6,6,6,6,15.25,
49.5,92,130,160.75,174.5,176,155,131.5,90.25,43.5,
11.75,6,6,6,6,6,6,6,6,6,6,6,6,19,60,
105.25,144,175,190.75,190.5,167.5,142.5,100.25,56.75,
15.5,6,6,6,6,6,6),
bp = c(760,760.25,761.5,762,762.75,
761.75,760.25,756.5,752.5,750,749,748.25,748,
747.5,747.25,747,747.75,748.5,750,751.75,753,754,
754.75,755.25,756,757.5,758,758.75,759,759.5,
760.25,756.75,753.75,752.75,749.75,748.25,748,747.5,
748,748,748.75,749.75,751,752.5,753.75,753.75,753,
754,753.75,754,755,755.25,756,756,755,753,750.75,
749,748,746,746,745.75,745.5,745.25,745.75,
746.5,747.75,748,748.75,751,751.75,751),
vws = c(-1.08,-1.18,-1.39,-1.62,
-1.48,-1.52,-1.42,-1.49,-1.81,-1.88,-1.78,-1.97,
-1.77,-1.84,-1.8,-2,-2.12,-2.04,-1.77,-1.46,-1.41,
-1.31,-1.17,-1.08,-1.12,-1.57,-1.53,-1.22,-1.53,
-1.49,-1.4,-1.46,-1.45,-1.34,-1.54,-2.04,-2.19,-2.09,
-2.12,-2.07,-2.13,-2.1,-1.96,-1.9,-1.52,-1.65,
-1.85,-2.12,-2.02,-2.08,-2.13,-2.14,-2.13,-2.17,
-2.12,-2.04,-1.92,-2.02,-1.94,-2.13,-2,-2.03,-2.09,
-2.14,-2.07,-2.08,-2.15,-1.95,-1.65,-1.38,-1.44,
-1.7),
xylene = c(0L,0L,0L,0L,0L,0L,0L,0L,
0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,
0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,
0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,
0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,
0L,0L,0L,0L,0L,0L,0L),
at = c(30.73,30.9,31.23,31.48,
31.55,31.77,31.1,29.82,28.35,27.4,26.82,26.52,26.25,
25.88,25.88,25.8,26.05,26.77,27.65,28.38,28.82,
29.25,29.48,29.68,29.92,30.25,30.45,30.65,30.67,
30.68,30.55,29.43,28.07,27.45,26.42,25.72,25.52,25.5,
25.62,25.72,26.1,26.8,27.52,28.05,28.65,28.98,
29.02,29.32,29.45,29.62,30,30.3,30.6,30.65,30.05,
29.1,28.1,27.48,27.03,26.73,26.55,26.3,26.4,26.5,
26.73,27.4,28.33,28.82,29.1,29.7,29.95,29.9)
)
# Relevant code
sample_data %>%
mutate(date = mdy_hms(date)) %>%
group_by(Datetime = floor_date(date, "day")) %>%
summarise(across(.cols = where(is.numeric),
.fns = mean,
rm.na = TRUE,
.names = "{.col}_mean"))
#> # A tibble: 3 × 17
#> Datetime pm2.5_mean no_mean no2_mean nox_mean so2_mean co_mean
#> <dttm> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 2020-04-01 00:00:00 88.1 20.8 135. 88.7 14.7 1.77
#> 2 2020-04-02 00:00:00 65.5 16.4 121. 77.4 15.8 1.67
#> 3 2020-04-03 00:00:00 50.1 11.3 136. 81.5 14.9 1.76
#> # … with 10 more variables: benzene_mean <dbl>, toulene_mean <dbl>,
#> # rh_mean <dbl>, ws_mean <dbl>, wd_mean <dbl>, sr_mean <dbl>, bp_mean <dbl>,
#> # vws_mean <dbl>, xylene_mean <dbl>, at_mean <dbl>
Created on 2022-03-17 by the reprex package (v2.0.1)
In order to help you we need to be able to reproduce your problem, that is why we ask you to provide a reproducible example as explained on the reprex guide I linked for you before.