0

There are 3 columns in my data, like this:

Date         Time    Measurement
01.01.2018   05:05   40
01.01.2018   05:10   50
02.01.2018   03:05   20

How can I sum up only those measurements that are larger than 30. I want a separate sum for each day.

The answer is for this example:

Date         Time    Measurement    Sum  Event
01.01.2018                          90   1
JenB
  • 17,620
  • 2
  • 17
  • 45
Bettina10
  • 23
  • 1
  • 6
  • 1
    Please show example input and output. You will get help *much faster* if you make your example copy/pasteable. `dput()` is very useful for making copy/pasteable versions of R objects. [There is a complete tutorial here on making reproducible R questions](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Gregor Thomas Jan 26 '18 at 15:12
  • 1
    In your current question, I can't tell if you want to do 1. and 2. separately or together? Also, what have you tried? Have you used any of the methods from the FAQ about [How to sum a variable by group?](https://stackoverflow.com/q/1660124/903061) – Gregor Thomas Jan 26 '18 at 15:12
  • 1
    If your dataset is `df`, try `aggregate(Measurement ~ Date, df, function(x) sum(x[x > 30]))`. – Rui Barradas Jan 26 '18 at 18:41

0 Answers0