0

I have rainfall data in V10, and I'm trying to aggregate it so that I can get the rainfall totals for each date. Having trouble using the zoo/aggregate functions. Any help is appreciated- thanks.

                 V1 V10 Date      Dates
2019-02-10 12:28:00 0.1 <NA> 2019-02-10
2019-02-11 11:23:00 0.1 <NA> 2019-02-11
2019-02-11 11:25:00 0.1 <NA> 2019-02-11
2019-02-11 11:28:00 0.1 <NA> 2019-02-11
2019-02-11 11:30:00 0.1 <NA> 2019-02-11
2019-02-11 11:33:00 0.1 <NA> 2019-02-11
Aaron Sun
  • 1
  • 1

1 Answers1

0

your first problem is that your data frame is not structured correctly, make sure you assign the right name to the right columns and to not use columns that have duplicate values as row names.

I did add V0 to the header just so R can read the table you pasted here.

require(dplyr)

my_df <- read.table(text =  
'V0 V1 V10 Date      Dates
2019-02-10 12:28:00 0.1 <NA> 2019-02-10
2019-02-11 11:23:00 0.1 <NA> 2019-02-11
2019-02-11 11:25:00 0.1 <NA> 2019-02-11
2019-02-11 11:28:00 0.1 <NA> 2019-02-11
2019-02-11 11:30:00 0.1 <NA> 2019-02-11
2019-02-11 11:33:00 0.1 <NA> 2019-02-11', header = TRUE)


my_df %>%  group_by(V0) %>%  summarise(V10 = sum(V10))

A tibble: 2 x 2
  V0           V10
  <fct>      <dbl>
1 2019-02-10   0.1
2 2019-02-11   0.5
Mouad_Seridi
  • 2,666
  • 15
  • 27