1
我有一個數據幀dt
:處理來港
structure(list(datetime = structure(c(1427846400, 1427850000,
1427853600, 1427857200, 1427860800, 1427864400, 1427868000, 1427871600,
1427875200, 1427878800, 1427882400, 1427886000, 1427889600, 1427893200,
1427896800, 1427900400, 1427904000, 1427907600, 1427911200, 1427914800,
1427918400, 1427922000, 1427925600, 1427929200, 1427932800, 1427936400,
1427940000, 1427943600, 1427947200, 1427950800), class = c("POSIXct",
"POSIXt"), tzone = "GMT"), precip = c(NA, 0.2, NA, 0.1, NA, NA,
0.4, 0.1, 0.2, 0.3, 1.1, 1, 0.8, 0.5, 0.5, NA, NA, 0.4, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), bin = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L,
3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c("2015-04-01 00:00:00",
"2015-04-01 06:00:00", "2015-04-01 12:00:00", "2015-04-01 18:00:00",
"2015-04-02 00:00:00", "2015-04-02 06:00:00", "2015-04-02 12:00:00",
"2015-04-02 18:00:00", "2015-04-03 00:00:00", "2015-04-03 06:00:00",
"2015-04-03 12:00:00", "2015-04-03 18:00:00", "2015-04-04 00:00:00",
"2015-04-04 06:00:00", "2015-04-04 12:00:00", "2015-04-04 18:00:00",
"2015-04-05 00:00:00", "2015-04-05 06:00:00", "2015-04-05 12:00:00",
"2015-04-05 18:00:00", "2015-04-06 00:00:00", "2015-04-06 06:00:00",
"2015-04-06 12:00:00", "2015-04-06 18:00:00", "2015-04-07 00:00:00",
"2015-04-07 06:00:00", "2015-04-07 12:00:00", "2015-04-07 18:00:00",
"2015-04-08 00:00:00", "2015-04-08 06:00:00", "2015-04-08 12:00:00",
"2015-04-08 18:00:00", "2015-04-09 00:00:00", "2015-04-09 06:00:00",
"2015-04-09 12:00:00", "2015-04-09 18:00:00", "2015-04-10 00:00:00",
"2015-04-10 06:00:00", "2015-04-10 12:00:00", "2015-04-10 18:00:00",
"2015-04-11 00:00:00", "2015-04-11 06:00:00", "2015-04-11 12:00:00",
"2015-04-11 18:00:00", "2015-04-12 00:00:00", "2015-04-12 06:00:00",
"2015-04-12 12:00:00", "2015-04-12 18:00:00", "2015-04-13 00:00:00",
"2015-04-13 06:00:00", "2015-04-13 12:00:00", "2015-04-13 18:00:00",
"2015-04-14 00:00:00", "2015-04-14 06:00:00", "2015-04-14 12:00:00",
"2015-04-14 18:00:00", "2015-04-15 00:00:00", "2015-04-15 06:00:00",
"2015-04-15 12:00:00", "2015-04-15 18:00:00", "2015-04-16 00:00:00",
"2015-04-16 06:00:00", "2015-04-16 12:00:00", "2015-04-16 18:00:00",
"2015-04-17 00:00:00", "2015-04-17 06:00:00", "2015-04-17 12:00:00",
"2015-04-17 18:00:00", "2015-04-18 00:00:00", "2015-04-18 06:00:00",
"2015-04-18 12:00:00", "2015-04-18 18:00:00", "2015-04-19 00:00:00",
"2015-04-19 06:00:00", "2015-04-19 12:00:00", "2015-04-19 18:00:00",
"2015-04-20 00:00:00", "2015-04-20 06:00:00", "2015-04-20 12:00:00",
"2015-04-20 18:00:00", "2015-04-21 00:00:00", "2015-04-21 06:00:00",
"2015-04-21 12:00:00", "2015-04-21 18:00:00", "2015-04-22 00:00:00",
"2015-04-22 06:00:00", "2015-04-22 12:00:00", "2015-04-22 18:00:00",
"2015-04-23 00:00:00", "2015-04-23 06:00:00", "2015-04-23 12:00:00",
"2015-04-23 18:00:00", "2015-04-24 00:00:00", "2015-04-24 06:00:00",
"2015-04-24 12:00:00", "2015-04-24 18:00:00", "2015-04-25 00:00:00",
"2015-04-25 06:00:00", "2015-04-25 12:00:00", "2015-04-25 18:00:00",
"2015-04-26 00:00:00", "2015-04-26 06:00:00", "2015-04-26 12:00:00",
"2015-04-26 18:00:00", "2015-04-27 00:00:00", "2015-04-27 06:00:00",
"2015-04-27 12:00:00", "2015-04-27 18:00:00", "2015-04-28 00:00:00",
"2015-04-28 06:00:00", "2015-04-28 12:00:00", "2015-04-28 18:00:00",
"2015-04-29 00:00:00", "2015-04-29 06:00:00", "2015-04-29 12:00:00",
"2015-04-29 18:00:00", "2015-04-30 00:00:00", "2015-04-30 06:00:00",
"2015-04-30 12:00:00", "2015-04-30 18:00:00", "2015-05-01 00:00:00",
"2015-05-01 06:00:00", "2015-05-01 12:00:00", "2015-05-01 18:00:00",
"2015-05-02 00:00:00", "2015-05-02 06:00:00", "2015-05-02 12:00:00",
"2015-05-02 18:00:00", "2015-05-03 00:00:00", "2015-05-03 06:00:00",
"2015-05-03 12:00:00", "2015-05-03 18:00:00", "2015-05-04 00:00:00",
"2015-05-04 06:00:00", "2015-05-04 12:00:00", "2015-05-04 18:00:00",
"2015-05-05 00:00:00", "2015-05-05 06:00:00", "2015-05-05 12:00:00",
"2015-05-05 18:00:00", "2015-05-06 00:00:00", "2015-05-06 06:00:00",
"2015-05-06 12:00:00", "2015-05-06 18:00:00", "2015-05-07 00:00:00",
"2015-05-07 06:00:00", "2015-05-07 12:00:00", "2015-05-07 18:00:00",
"2015-05-08 00:00:00", "2015-05-08 06:00:00", "2015-05-08 12:00:00",
"2015-05-08 18:00:00", "2015-05-09 00:00:00", "2015-05-09 06:00:00",
"2015-05-09 12:00:00", "2015-05-09 18:00:00", "2015-05-10 00:00:00",
"2015-05-10 06:00:00", "2015-05-10 12:00:00", "2015-05-10 18:00:00",
"2015-05-11 00:00:00", "2015-05-11 06:00:00", "2015-05-11 12:00:00",
"2015-05-11 18:00:00", "2015-05-12 00:00:00", "2015-05-12 06:00:00",
"2015-05-12 12:00:00", "2015-05-12 18:00:00", "2015-05-13 00:00:00",
"2015-05-13 06:00:00", "2015-05-13 12:00:00", "2015-05-13 18:00:00",
"2015-05-14 00:00:00", "2015-05-14 06:00:00", "2015-05-14 12:00:00",
"2015-05-14 18:00:00", "2015-05-15 00:00:00", "2015-05-15 06:00:00",
"2015-05-15 12:00:00", "2015-05-15 18:00:00", "2015-05-16 00:00:00",
"2015-05-16 06:00:00", "2015-05-16 12:00:00", "2015-05-16 18:00:00",
"2015-05-17 00:00:00", "2015-05-17 06:00:00", "2015-05-17 12:00:00",
"2015-05-17 18:00:00", "2015-05-18 00:00:00", "2015-05-18 06:00:00",
"2015-05-18 12:00:00", "2015-05-18 18:00:00", "2015-05-19 00:00:00",
"2015-05-19 06:00:00", "2015-05-19 12:00:00", "2015-05-19 18:00:00",
"2015-05-20 00:00:00", "2015-05-20 06:00:00", "2015-05-20 12:00:00",
"2015-05-20 18:00:00", "2015-05-21 00:00:00", "2015-05-21 06:00:00",
"2015-05-21 12:00:00", "2015-05-21 18:00:00", "2015-05-22 00:00:00",
"2015-05-22 06:00:00", "2015-05-22 12:00:00", "2015-05-22 18:00:00",
"2015-05-23 00:00:00", "2015-05-23 06:00:00", "2015-05-23 12:00:00",
"2015-05-23 18:00:00", "2015-05-24 00:00:00", "2015-05-24 06:00:00",
"2015-05-24 12:00:00", "2015-05-24 18:00:00", "2015-05-25 00:00:00",
"2015-05-25 06:00:00", "2015-05-25 12:00:00", "2015-05-25 18:00:00",
"2015-05-26 00:00:00", "2015-05-26 06:00:00", "2015-05-26 12:00:00",
"2015-05-26 18:00:00", "2015-05-27 00:00:00", "2015-05-27 06:00:00",
"2015-05-27 12:00:00", "2015-05-27 18:00:00", "2015-05-28 00:00:00",
"2015-05-28 06:00:00", "2015-05-28 12:00:00", "2015-05-28 18:00:00",
"2015-05-29 00:00:00", "2015-05-29 06:00:00", "2015-05-29 12:00:00",
"2015-05-29 18:00:00", "2015-05-30 00:00:00", "2015-05-30 06:00:00",
"2015-05-30 12:00:00", "2015-05-30 18:00:00", "2015-05-31 00:00:00",
"2015-05-31 06:00:00", "2015-05-31 12:00:00", "2015-05-31 18:00:00",
"2015-06-01 00:00:00", "2015-06-01 06:00:00", "2015-06-01 12:00:00",
"2015-06-01 18:00:00", "2015-06-02 00:00:00", "2015-06-02 06:00:00",
"2015-06-02 12:00:00", "2015-06-02 18:00:00", "2015-06-03 00:00:00",
"2015-06-03 06:00:00", "2015-06-03 12:00:00", "2015-06-03 18:00:00",
"2015-06-04 00:00:00", "2015-06-04 06:00:00", "2015-06-04 12:00:00",
"2015-06-04 18:00:00", "2015-06-05 00:00:00", "2015-06-05 06:00:00",
"2015-06-05 12:00:00", "2015-06-05 18:00:00", "2015-06-06 00:00:00",
"2015-06-06 06:00:00", "2015-06-06 12:00:00", "2015-06-06 18:00:00",
"2015-06-07 00:00:00", "2015-06-07 06:00:00", "2015-06-07 12:00:00",
"2015-06-07 18:00:00", "2015-06-08 00:00:00", "2015-06-08 06:00:00",
"2015-06-08 12:00:00", "2015-06-08 18:00:00", "2015-06-09 00:00:00",
"2015-06-09 06:00:00", "2015-06-09 12:00:00", "2015-06-09 18:00:00",
"2015-06-10 00:00:00", "2015-06-10 06:00:00", "2015-06-10 12:00:00",
"2015-06-10 18:00:00", "2015-06-11 00:00:00", "2015-06-11 06:00:00",
"2015-06-11 12:00:00", "2015-06-11 18:00:00", "2015-06-12 00:00:00",
"2015-06-12 06:00:00", "2015-06-12 12:00:00", "2015-06-12 18:00:00",
"2015-06-13 00:00:00", "2015-06-13 06:00:00", "2015-06-13 12:00:00",
"2015-06-13 18:00:00", "2015-06-14 00:00:00", "2015-06-14 06:00:00",
"2015-06-14 12:00:00", "2015-06-14 18:00:00", "2015-06-15 00:00:00",
"2015-06-15 06:00:00", "2015-06-15 12:00:00", "2015-06-15 18:00:00",
"2015-06-16 00:00:00", "2015-06-16 06:00:00", "2015-06-16 12:00:00",
"2015-06-16 18:00:00", "2015-06-17 00:00:00", "2015-06-17 06:00:00",
"2015-06-17 12:00:00", "2015-06-17 18:00:00", "2015-06-18 00:00:00",
"2015-06-18 06:00:00", "2015-06-18 12:00:00", "2015-06-18 18:00:00",
"2015-06-19 00:00:00", "2015-06-19 06:00:00", "2015-06-19 12:00:00",
"2015-06-19 18:00:00", "2015-06-20 00:00:00", "2015-06-20 06:00:00",
"2015-06-20 12:00:00", "2015-06-20 18:00:00", "2015-06-21 00:00:00",
"2015-06-21 06:00:00", "2015-06-21 12:00:00", "2015-06-21 18:00:00",
"2015-06-22 00:00:00", "2015-06-22 06:00:00", "2015-06-22 12:00:00",
"2015-06-22 18:00:00", "2015-06-23 00:00:00", "2015-06-23 06:00:00",
"2015-06-23 12:00:00", "2015-06-23 18:00:00", "2015-06-24 00:00:00",
"2015-06-24 06:00:00", "2015-06-24 12:00:00", "2015-06-24 18:00:00",
"2015-06-25 00:00:00", "2015-06-25 06:00:00", "2015-06-25 12:00:00",
"2015-06-25 18:00:00", "2015-06-26 00:00:00", "2015-06-26 06:00:00",
"2015-06-26 12:00:00", "2015-06-26 18:00:00", "2015-06-27 00:00:00",
"2015-06-27 06:00:00", "2015-06-27 12:00:00", "2015-06-27 18:00:00",
"2015-06-28 00:00:00", "2015-06-28 06:00:00", "2015-06-28 12:00:00",
"2015-06-28 18:00:00", "2015-06-29 00:00:00", "2015-06-29 06:00:00",
"2015-06-29 12:00:00", "2015-06-29 18:00:00", "2015-06-30 00:00:00",
"2015-06-30 06:00:00", "2015-06-30 12:00:00", "2015-06-30 18:00:00",
"2015-07-01 00:00:00", "2015-07-01 06:00:00", "2015-07-01 12:00:00",
"2015-07-01 18:00:00", "2015-07-02 00:00:00", "2015-07-02 06:00:00",
"2015-07-02 12:00:00", "2015-07-02 18:00:00", "2015-07-03 00:00:00",
"2015-07-03 06:00:00", "2015-07-03 12:00:00", "2015-07-03 18:00:00",
"2015-07-04 00:00:00", "2015-07-04 06:00:00", "2015-07-04 12:00:00",
"2015-07-04 18:00:00", "2015-07-05 00:00:00", "2015-07-05 06:00:00",
"2015-07-05 12:00:00", "2015-07-05 18:00:00", "2015-07-06 00:00:00",
"2015-07-06 06:00:00", "2015-07-06 12:00:00", "2015-07-06 18:00:00",
"2015-07-07 00:00:00", "2015-07-07 06:00:00", "2015-07-07 12:00:00",
"2015-07-07 18:00:00", "2015-07-08 00:00:00", "2015-07-08 06:00:00",
"2015-07-08 12:00:00", "2015-07-08 18:00:00", "2015-07-09 00:00:00",
"2015-07-09 06:00:00", "2015-07-09 12:00:00", "2015-07-09 18:00:00",
"2015-07-10 00:00:00", "2015-07-10 06:00:00", "2015-07-10 12:00:00",
"2015-07-10 18:00:00", "2015-07-11 00:00:00", "2015-07-11 06:00:00",
"2015-07-11 12:00:00", "2015-07-11 18:00:00", "2015-07-12 00:00:00",
"2015-07-12 06:00:00", "2015-07-12 12:00:00", "2015-07-12 18:00:00",
"2015-07-13 00:00:00", "2015-07-13 06:00:00", "2015-07-13 12:00:00",
"2015-07-13 18:00:00", "2015-07-14 00:00:00", "2015-07-14 06:00:00",
"2015-07-14 12:00:00", "2015-07-14 18:00:00", "2015-07-15 00:00:00",
"2015-07-15 06:00:00", "2015-07-15 12:00:00", "2015-07-15 18:00:00",
"2015-07-16 00:00:00", "2015-07-16 06:00:00", "2015-07-16 12:00:00",
"2015-07-16 18:00:00", "2015-07-17 00:00:00", "2015-07-17 06:00:00",
"2015-07-17 12:00:00", "2015-07-17 18:00:00", "2015-07-18 00:00:00",
"2015-07-18 06:00:00", "2015-07-18 12:00:00", "2015-07-18 18:00:00",
"2015-07-19 00:00:00", "2015-07-19 06:00:00", "2015-07-19 12:00:00",
"2015-07-19 18:00:00", "2015-07-20 00:00:00", "2015-07-20 06:00:00",
"2015-07-20 12:00:00", "2015-07-20 18:00:00", "2015-07-21 00:00:00",
"2015-07-21 06:00:00", "2015-07-21 12:00:00", "2015-07-21 18:00:00",
"2015-07-22 00:00:00", "2015-07-22 06:00:00", "2015-07-22 12:00:00",
"2015-07-22 18:00:00", "2015-07-23 00:00:00", "2015-07-23 06:00:00",
"2015-07-23 12:00:00", "2015-07-23 18:00:00", "2015-07-24 00:00:00",
"2015-07-24 06:00:00", "2015-07-24 12:00:00", "2015-07-24 18:00:00",
"2015-07-25 00:00:00", "2015-07-25 06:00:00", "2015-07-25 12:00:00",
"2015-07-25 18:00:00", "2015-07-26 00:00:00", "2015-07-26 06:00:00",
"2015-07-26 12:00:00", "2015-07-26 18:00:00", "2015-07-27 00:00:00",
"2015-07-27 06:00:00", "2015-07-27 12:00:00", "2015-07-27 18:00:00",
"2015-07-28 00:00:00", "2015-07-28 06:00:00", "2015-07-28 12:00:00",
"2015-07-28 18:00:00", "2015-07-29 00:00:00", "2015-07-29 06:00:00",
"2015-07-29 12:00:00", "2015-07-29 18:00:00", "2015-07-30 00:00:00",
"2015-07-30 06:00:00", "2015-07-30 12:00:00", "2015-07-30 18:00:00",
"2015-07-31 00:00:00", "2015-07-31 06:00:00", "2015-07-31 12:00:00",
"2015-07-31 18:00:00", "2015-08-01 00:00:00", "2015-08-01 06:00:00",
"2015-08-01 12:00:00", "2015-08-01 18:00:00", "2015-08-02 00:00:00",
"2015-08-02 06:00:00", "2015-08-02 12:00:00", "2015-08-02 18:00:00",
"2015-08-03 00:00:00", "2015-08-03 06:00:00", "2015-08-03 12:00:00",
"2015-08-03 18:00:00", "2015-08-04 00:00:00", "2015-08-04 06:00:00",
"2015-08-04 12:00:00", "2015-08-04 18:00:00", "2015-08-05 00:00:00",
"2015-08-05 06:00:00", "2015-08-05 12:00:00", "2015-08-05 18:00:00",
"2015-08-06 00:00:00", "2015-08-06 06:00:00", "2015-08-06 12:00:00",
"2015-08-06 18:00:00", "2015-08-07 00:00:00", "2015-08-07 06:00:00",
"2015-08-07 12:00:00", "2015-08-07 18:00:00", "2015-08-08 00:00:00",
"2015-08-08 06:00:00", "2015-08-08 12:00:00", "2015-08-08 18:00:00",
"2015-08-09 00:00:00", "2015-08-09 06:00:00", "2015-08-09 12:00:00",
"2015-08-09 18:00:00", "2015-08-10 00:00:00", "2015-08-10 06:00:00",
"2015-08-10 12:00:00", "2015-08-10 18:00:00", "2015-08-11 00:00:00",
"2015-08-11 06:00:00", "2015-08-11 12:00:00", "2015-08-11 18:00:00",
"2015-08-12 00:00:00", "2015-08-12 06:00:00", "2015-08-12 12:00:00",
"2015-08-12 18:00:00", "2015-08-13 00:00:00", "2015-08-13 06:00:00",
"2015-08-13 12:00:00", "2015-08-13 18:00:00", "2015-08-14 00:00:00",
"2015-08-14 06:00:00", "2015-08-14 12:00:00", "2015-08-14 18:00:00",
"2015-08-15 00:00:00", "2015-08-15 06:00:00", "2015-08-15 12:00:00",
"2015-08-15 18:00:00", "2015-08-16 00:00:00", "2015-08-16 06:00:00",
"2015-08-16 12:00:00", "2015-08-16 18:00:00", "2015-08-17 00:00:00",
"2015-08-17 06:00:00", "2015-08-17 12:00:00", "2015-08-17 18:00:00",
"2015-08-18 00:00:00", "2015-08-18 06:00:00", "2015-08-18 12:00:00",
"2015-08-18 18:00:00", "2015-08-19 00:00:00", "2015-08-19 06:00:00",
"2015-08-19 12:00:00", "2015-08-19 18:00:00", "2015-08-20 00:00:00",
"2015-08-20 06:00:00", "2015-08-20 12:00:00", "2015-08-20 18:00:00",
"2015-08-21 00:00:00", "2015-08-21 06:00:00", "2015-08-21 12:00:00",
"2015-08-21 18:00:00", "2015-08-22 00:00:00", "2015-08-22 06:00:00",
"2015-08-22 12:00:00", "2015-08-22 18:00:00", "2015-08-23 00:00:00",
"2015-08-23 06:00:00", "2015-08-23 12:00:00", "2015-08-23 18:00:00",
"2015-08-24 00:00:00", "2015-08-24 06:00:00", "2015-08-24 12:00:00",
"2015-08-24 18:00:00", "2015-08-25 00:00:00", "2015-08-25 06:00:00",
"2015-08-25 12:00:00", "2015-08-25 18:00:00", "2015-08-26 00:00:00",
"2015-08-26 06:00:00", "2015-08-26 12:00:00", "2015-08-26 18:00:00",
"2015-08-27 00:00:00", "2015-08-27 06:00:00", "2015-08-27 12:00:00",
"2015-08-27 18:00:00", "2015-08-28 00:00:00", "2015-08-28 06:00:00",
"2015-08-28 12:00:00", "2015-08-28 18:00:00", "2015-08-29 00:00:00",
"2015-08-29 06:00:00", "2015-08-29 12:00:00", "2015-08-29 18:00:00",
"2015-08-30 00:00:00", "2015-08-30 06:00:00", "2015-08-30 12:00:00",
"2015-08-30 18:00:00", "2015-08-31 00:00:00", "2015-08-31 06:00:00",
"2015-08-31 12:00:00", "2015-08-31 18:00:00", "2015-09-01 00:00:00",
"2015-09-01 06:00:00", "2015-09-01 12:00:00", "2015-09-01 18:00:00",
"2015-09-02 00:00:00", "2015-09-02 06:00:00", "2015-09-02 12:00:00",
"2015-09-02 18:00:00", "2015-09-03 00:00:00", "2015-09-03 06:00:00",
"2015-09-03 12:00:00", "2015-09-03 18:00:00", "2015-09-04 00:00:00",
"2015-09-04 06:00:00", "2015-09-04 12:00:00", "2015-09-04 18:00:00",
"2015-09-05 00:00:00", "2015-09-05 06:00:00", "2015-09-05 12:00:00",
"2015-09-05 18:00:00", "2015-09-06 00:00:00", "2015-09-06 06:00:00",
"2015-09-06 12:00:00", "2015-09-06 18:00:00", "2015-09-07 00:00:00",
"2015-09-07 06:00:00", "2015-09-07 12:00:00", "2015-09-07 18:00:00",
"2015-09-08 00:00:00", "2015-09-08 06:00:00", "2015-09-08 12:00:00",
"2015-09-08 18:00:00", "2015-09-09 00:00:00", "2015-09-09 06:00:00",
"2015-09-09 12:00:00", "2015-09-09 18:00:00", "2015-09-10 00:00:00",
"2015-09-10 06:00:00", "2015-09-10 12:00:00", "2015-09-10 18:00:00",
"2015-09-11 00:00:00", "2015-09-11 06:00:00", "2015-09-11 12:00:00",
"2015-09-11 18:00:00", "2015-09-12 00:00:00", "2015-09-12 06:00:00",
"2015-09-12 12:00:00", "2015-09-12 18:00:00", "2015-09-13 00:00:00",
"2015-09-13 06:00:00", "2015-09-13 12:00:00", "2015-09-13 18:00:00",
"2015-09-14 00:00:00", "2015-09-14 06:00:00", "2015-09-14 12:00:00",
"2015-09-14 18:00:00", "2015-09-15 00:00:00", "2015-09-15 06:00:00",
"2015-09-15 12:00:00", "2015-09-15 18:00:00", "2015-09-16 00:00:00",
"2015-09-16 06:00:00", "2015-09-16 12:00:00", "2015-09-16 18:00:00",
"2015-09-17 00:00:00", "2015-09-17 06:00:00", "2015-09-17 12:00:00",
"2015-09-17 18:00:00", "2015-09-18 00:00:00", "2015-09-18 06:00:00",
"2015-09-18 12:00:00", "2015-09-18 18:00:00", "2015-09-19 00:00:00",
"2015-09-19 06:00:00", "2015-09-19 12:00:00", "2015-09-19 18:00:00",
"2015-09-20 00:00:00", "2015-09-20 06:00:00", "2015-09-20 12:00:00",
"2015-09-20 18:00:00", "2015-09-21 00:00:00", "2015-09-21 06:00:00",
"2015-09-21 12:00:00", "2015-09-21 18:00:00", "2015-09-22 00:00:00",
"2015-09-22 06:00:00", "2015-09-22 12:00:00", "2015-09-22 18:00:00",
"2015-09-23 00:00:00", "2015-09-23 06:00:00", "2015-09-23 12:00:00",
"2015-09-23 18:00:00", "2015-09-24 00:00:00", "2015-09-24 06:00:00",
"2015-09-24 12:00:00", "2015-09-24 18:00:00", "2015-09-25 00:00:00",
"2015-09-25 06:00:00", "2015-09-25 12:00:00", "2015-09-25 18:00:00",
"2015-09-26 00:00:00", "2015-09-26 06:00:00", "2015-09-26 12:00:00",
"2015-09-26 18:00:00", "2015-09-27 00:00:00", "2015-09-27 06:00:00",
"2015-09-27 12:00:00", "2015-09-27 18:00:00", "2015-09-28 00:00:00",
"2015-09-28 06:00:00", "2015-09-28 12:00:00", "2015-09-28 18:00:00",
"2015-09-29 00:00:00", "2015-09-29 06:00:00", "2015-09-29 12:00:00",
"2015-09-29 18:00:00", "2015-09-30 00:00:00", "2015-09-30 06:00:00",
"2015-09-30 12:00:00", "2015-09-30 18:00:00", "2015-10-01 00:00:00",
"2015-10-01 06:00:00", "2015-10-01 12:00:00", "2015-10-01 18:00:00",
"2015-10-02 00:00:00", "2015-10-02 06:00:00", "2015-10-02 12:00:00",
"2015-10-02 18:00:00", "2015-10-03 00:00:00", "2015-10-03 06:00:00",
"2015-10-03 12:00:00", "2015-10-03 18:00:00", "2015-10-04 00:00:00",
"2015-10-04 06:00:00", "2015-10-04 12:00:00", "2015-10-04 18:00:00",
"2015-10-05 00:00:00", "2015-10-05 06:00:00", "2015-10-05 12:00:00",
"2015-10-05 18:00:00", "2015-10-06 00:00:00", "2015-10-06 06:00:00",
"2015-10-06 12:00:00", "2015-10-06 18:00:00", "2015-10-07 00:00:00",
"2015-10-07 06:00:00", "2015-10-07 12:00:00", "2015-10-07 18:00:00",
"2015-10-08 00:00:00", "2015-10-08 06:00:00", "2015-10-08 12:00:00",
"2015-10-08 18:00:00", "2015-10-09 00:00:00", "2015-10-09 06:00:00",
"2015-10-09 12:00:00", "2015-10-09 18:00:00", "2015-10-10 00:00:00",
"2015-10-10 06:00:00", "2015-10-10 12:00:00", "2015-10-10 18:00:00",
"2015-10-11 00:00:00", "2015-10-11 06:00:00", "2015-10-11 12:00:00",
"2015-10-11 18:00:00", "2015-10-12 00:00:00", "2015-10-12 06:00:00",
"2015-10-12 12:00:00", "2015-10-12 18:00:00", "2015-10-13 00:00:00",
"2015-10-13 06:00:00", "2015-10-13 12:00:00", "2015-10-13 18:00:00",
"2015-10-14 00:00:00", "2015-10-14 06:00:00", "2015-10-14 12:00:00",
"2015-10-14 18:00:00", "2015-10-15 00:00:00", "2015-10-15 06:00:00",
"2015-10-15 12:00:00", "2015-10-15 18:00:00", "2015-10-16 00:00:00",
"2015-10-16 06:00:00", "2015-10-16 12:00:00", "2015-10-16 18:00:00",
"2015-10-17 00:00:00", "2015-10-17 06:00:00", "2015-10-17 12:00:00",
"2015-10-17 18:00:00", "2015-10-18 00:00:00", "2015-10-18 06:00:00",
"2015-10-18 12:00:00", "2015-10-18 18:00:00", "2015-10-19 00:00:00",
"2015-10-19 06:00:00", "2015-10-19 12:00:00", "2015-10-19 18:00:00",
"2015-10-20 00:00:00", "2015-10-20 06:00:00", "2015-10-20 12:00:00",
"2015-10-20 18:00:00", "2015-10-21 00:00:00", "2015-10-21 06:00:00",
"2015-10-21 12:00:00", "2015-10-21 18:00:00", "2015-10-22 00:00:00",
"2015-10-22 06:00:00", "2015-10-22 12:00:00", "2015-10-22 18:00:00",
"2015-10-23 00:00:00", "2015-10-23 06:00:00", "2015-10-23 12:00:00",
"2015-10-23 18:00:00", "2015-10-24 00:00:00", "2015-10-24 06:00:00",
"2015-10-24 12:00:00", "2015-10-24 18:00:00", "2015-10-25 00:00:00",
"2015-10-25 06:00:00", "2015-10-25 12:00:00", "2015-10-25 18:00:00",
"2015-10-26 00:00:00", "2015-10-26 06:00:00", "2015-10-26 12:00:00",
"2015-10-26 18:00:00", "2015-10-27 00:00:00", "2015-10-27 06:00:00",
"2015-10-27 12:00:00", "2015-10-27 18:00:00", "2015-10-28 00:00:00",
"2015-10-28 06:00:00", "2015-10-28 12:00:00", "2015-10-28 18:00:00",
"2015-10-29 00:00:00", "2015-10-29 06:00:00", "2015-10-29 12:00:00",
"2015-10-29 18:00:00", "2015-10-30 00:00:00", "2015-10-30 06:00:00",
"2015-10-30 12:00:00", "2015-10-30 18:00:00", "2015-10-31 00:00:00",
"2015-10-31 06:00:00", "2015-10-31 12:00:00", "2015-10-31 18:00:00",
"2015-11-01 00:00:00", "2015-11-01 06:00:00", "2015-11-01 12:00:00",
"2015-11-01 18:00:00", "2015-11-02 00:00:00", "2015-11-02 06:00:00",
"2015-11-02 12:00:00", "2015-11-02 18:00:00", "2015-11-03 00:00:00",
"2015-11-03 06:00:00", "2015-11-03 12:00:00", "2015-11-03 18:00:00",
"2015-11-04 00:00:00", "2015-11-04 06:00:00", "2015-11-04 12:00:00",
"2015-11-04 18:00:00", "2015-11-05 00:00:00", "2015-11-05 06:00:00",
"2015-11-05 12:00:00", "2015-11-05 18:00:00", "2015-11-06 00:00:00",
"2015-11-06 06:00:00", "2015-11-06 12:00:00", "2015-11-06 18:00:00",
"2015-11-07 00:00:00", "2015-11-07 06:00:00", "2015-11-07 12:00:00",
"2015-11-07 18:00:00", "2015-11-08 00:00:00", "2015-11-08 06:00:00",
"2015-11-08 12:00:00", "2015-11-08 18:00:00", "2015-11-09 00:00:00",
"2015-11-09 06:00:00", "2015-11-09 12:00:00", "2015-11-09 18:00:00",
"2015-11-10 00:00:00", "2015-11-10 06:00:00", "2015-11-10 12:00:00",
"2015-11-10 18:00:00", "2015-11-11 00:00:00", "2015-11-11 06:00:00",
"2015-11-11 12:00:00", "2015-11-11 18:00:00", "2015-11-12 00:00:00",
"2015-11-12 06:00:00", "2015-11-12 12:00:00", "2015-11-12 18:00:00",
"2015-11-13 00:00:00", "2015-11-13 06:00:00", "2015-11-13 12:00:00",
"2015-11-13 18:00:00", "2015-11-14 00:00:00", "2015-11-14 06:00:00",
"2015-11-14 12:00:00", "2015-11-14 18:00:00", "2015-11-15 00:00:00",
"2015-11-15 06:00:00", "2015-11-15 12:00:00", "2015-11-15 18:00:00",
"2015-11-16 00:00:00", "2015-11-16 06:00:00", "2015-11-16 12:00:00",
"2015-11-16 18:00:00", "2015-11-17 00:00:00", "2015-11-17 06:00:00",
"2015-11-17 12:00:00", "2015-11-17 18:00:00", "2015-11-18 00:00:00",
"2015-11-18 06:00:00", "2015-11-18 12:00:00", "2015-11-18 18:00:00",
"2015-11-19 00:00:00", "2015-11-19 06:00:00", "2015-11-19 12:00:00",
"2015-11-19 18:00:00", "2015-11-20 00:00:00", "2015-11-20 06:00:00",
"2015-11-20 12:00:00", "2015-11-20 18:00:00", "2015-11-21 00:00:00",
"2015-11-21 06:00:00", "2015-11-21 12:00:00", "2015-11-21 18:00:00",
"2015-11-22 00:00:00", "2015-11-22 06:00:00", "2015-11-22 12:00:00",
"2015-11-22 18:00:00", "2015-11-23 00:00:00", "2015-11-23 06:00:00",
"2015-11-23 12:00:00", "2015-11-23 18:00:00", "2015-11-24 00:00:00",
"2015-11-24 06:00:00", "2015-11-24 12:00:00", "2015-11-24 18:00:00",
"2015-11-25 00:00:00", "2015-11-25 06:00:00", "2015-11-25 12:00:00",
"2015-11-25 18:00:00", "2015-11-26 00:00:00", "2015-11-26 06:00:00",
"2015-11-26 12:00:00", "2015-11-26 18:00:00", "2015-11-27 00:00:00",
"2015-11-27 06:00:00", "2015-11-27 12:00:00", "2015-11-27 18:00:00",
"2015-11-28 00:00:00", "2015-11-28 06:00:00", "2015-11-28 12:00:00",
"2015-11-28 18:00:00", "2015-11-29 00:00:00", "2015-11-29 06:00:00",
"2015-11-29 12:00:00", "2015-11-29 18:00:00", "2015-11-30 00:00:00",
"2015-11-30 06:00:00", "2015-11-30 12:00:00", "2015-11-30 18:00:00"
), class = "factor")), .Names = c("datetime", "precip", "bin"
), row.names = c(NA, 30L), class = "data.frame")
的意圖是通過bin
聚集dt$precip
並返回NAs
其中dt$precip
擁有所有NAs
在bin和忽略NAs
在其中的價值觀和NAs
並存完事。我試過了:
tri <- aggregate(dt$precip, list(dt$bin), FUN=sum, na.rm=T)
tri
Group.1 x
1 2015-04-01 00:00:00 0.3
2 2015-04-01 06:00:00 3.1
3 2015-04-01 12:00:00 2.2
4 2015-04-01 18:00:00 0.0
5 2015-04-02 00:00:00 0.0
總和和刪除/忽略前三個箱子中的NA是正確的。但是,它將zeros
插入最後兩個倉中,而不是NAs
。我需要NAs
。
我曾嘗試:
tri <- aggregate(dt$precip, list(dt$bin), FUN=sum, na.rm=TRUE, na.action=na.omit)
Error in FUN(X[[1L]], ...) : invalid 'type' (closure) of argument
和
tri <- aggregate(dt$precip, list(dt$bin), function(x) sum(x, na.rm=TRUE), na.action = na.pass)
Error in FUN(X[[1L]], ...) :
unused argument (na.action = function (object, ...)
object)
tri <- aggregate(dt$precip, list(dt$bin), FUN=sum, na.rm=TRUE, na.action="na.pass")
Error in FUN(X[[1L]], ...) : invalid 'type' (character) of argument
任何事情,我在這裏失蹤?我有> 20,000個文件,並且我的整個代碼都集中在aggregate
函數中。我知道其他方法使用dplyr
和data.table
等存在,但我會明白一個解決方案,使用aggregate
尤其是在list
對象。
偉大的回答得到
sum
我們可以創建一個例外返回NA
。你拯救了我的一天。我的分析出錯了,因爲我無法從發病的時候趕上'0s'。現在一切看起來都很有希望。在列表中:'ret = lapply(sixhours1,function(y)aggregate(precip-bin,y,FUN = function(x)if(all(is.na(x)))NA else sum(x,na.rm = TRUE),na.action = na.pass))' – code123@ code123感謝您的反饋。很高興知道它的工作原理。 – akrun