R how Sum values by group by date

andrew

I have this table already in variable DATA in R, loaded from csv

country, date, confirmed    
Afghanistan, 2020-03-16, 21
Afghanistan, 2020-03-17, 22
Afghanistan, 2020-03-18, 22
Albania, 2020-03-16, 23
Albania, 2020-03-17, 33
Albania, 2020-03-18, 38
...

I would like to make this query in R

select date, sum(confirmed) as confirmed FROM `Table` group by date

Any idea pls ?

So results should be this

date,confirmed
2020-03-16, 44
2020-03-17, 55
2020-03-18, 60
akrun

With aggregate from base R

aggregate(confirmed ~ date, Table, sum, na.rm = TRUE)

Or with dplyr

library(dplyr)
Table %>%
  group_by(date) %>%
  summarise(confirmed = sum(confirmed, na.rm = TRUE))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to sum values of two tables and group by date

From Dev

R sum by group if date within date range

From Dev

How to group multiple rows based on some criteria and sum values in R?

From Dev

Group Daily Date Columns by Month and Sum Values

From Dev

sum consecutive values in the same group ordered by date

From Dev

How to group and sum integer values

From Dev

How to do sum with where clause group by with date?

From Dev

How to group date by day and sum in postgres?

From Dev

SQL: How to count the sum of values without GROUP BY

From Dev

How to group and sum values from array of objects?

From Dev

How to use GROUP BY to sum values in MySQL

From Dev

how to sum a list of max values group by

From Dev

Group non-unique datetime column by date and sum values in python

From Dev

R replace minimum date values per group

From Dev

How to "SUM" unique column Values And Filter By Date

From Dev

Expanding sum with group by date

From Dev

SQL: Group by date, and sum

From Dev

How to sum within a group of values and then take the difference from another group?

From Dev

How to compute a sum based on the 2 biggest values for each group (group by)?

From Dev

How to decode json, group by a column value, and sum values in each group?

From Dev

R: count unique values from group to group by date

From Dev

How to group by mixed values and sort by date in a PivotTable?

From Dev

how to find the sum of the n largest values by group of values in a pandas dataframe?

From Dev

How to sum values in dataframe until certain values in other column by group?

From Dev

sum the value after group_by and based on date time format in R

From Dev

How to sum over NA rows by group in R

From Dev

How to group and sum using a loop in R?

From Dev

How to group and sum by multiple conditions in R

From Dev

How to get tally (rolling sum) by group in R?

Related Related

  1. 1

    How to sum values of two tables and group by date

  2. 2

    R sum by group if date within date range

  3. 3

    How to group multiple rows based on some criteria and sum values in R?

  4. 4

    Group Daily Date Columns by Month and Sum Values

  5. 5

    sum consecutive values in the same group ordered by date

  6. 6

    How to group and sum integer values

  7. 7

    How to do sum with where clause group by with date?

  8. 8

    How to group date by day and sum in postgres?

  9. 9

    SQL: How to count the sum of values without GROUP BY

  10. 10

    How to group and sum values from array of objects?

  11. 11

    How to use GROUP BY to sum values in MySQL

  12. 12

    how to sum a list of max values group by

  13. 13

    Group non-unique datetime column by date and sum values in python

  14. 14

    R replace minimum date values per group

  15. 15

    How to "SUM" unique column Values And Filter By Date

  16. 16

    Expanding sum with group by date

  17. 17

    SQL: Group by date, and sum

  18. 18

    How to sum within a group of values and then take the difference from another group?

  19. 19

    How to compute a sum based on the 2 biggest values for each group (group by)?

  20. 20

    How to decode json, group by a column value, and sum values in each group?

  21. 21

    R: count unique values from group to group by date

  22. 22

    How to group by mixed values and sort by date in a PivotTable?

  23. 23

    how to find the sum of the n largest values by group of values in a pandas dataframe?

  24. 24

    How to sum values in dataframe until certain values in other column by group?

  25. 25

    sum the value after group_by and based on date time format in R

  26. 26

    How to sum over NA rows by group in R

  27. 27

    How to group and sum using a loop in R?

  28. 28

    How to group and sum by multiple conditions in R

  29. 29

    How to get tally (rolling sum) by group in R?

HotTag

Archive