I have below dataset:
ClaimType ClaimDay ClaimCost dates month day
1 1 1 10811 1970-01-01 1 1970-01-01
2 1 1 18078 1970-01-01 1 1970-01-01
3 1 2 44579 1970-01-01 1 1970-01-02
4 1 3 23710 1970-01-01 1 1970-01-03
5 1 4 29580 1970-01-01 1 1970-01-04
6 1 4 36208 1970-01-01 1 1970-01-04
I would like to create a new dataset with the columns "claim day" and "day". Claim day should be counted per value. So for example since we have two ones, a two, a three and then two fours I would like the new dataset to be like:
ClaimDay day
2 1970-01-01
1 1970-01-02
1 1970-01-03
2 1970-01-04
As you can see the Claimday and day are related.
I have tried
mydata <- aggregate(ClaimDay~Day,FUN=sum,data=mydata)$ClaimDay
But the problem is, then it counts the summary when aggregate.
Can anyone help me with my issue?