Quite a simple task I guess... I am trying to calculate the mean price per day. There are 3 different days here and each has some price. This is the DataFrame I initially have
ID Date RoomAv Price
1 2001-01-02 TRUE 110
2 2001-01-04 FALSE 120
3 2001-01-03 TRUE 130
4 2001-01-03 TRUE 140
5 2001-01-03 TRUE 150
6 2001-01-02 FALSE 160
7 2001-01-02 TRUE 170
8 2001-01-04 TRUE 180
9 2001-01-04 FALSE 190
10 2001-01-02 TRUE 200
I need it to be something like this
Date AveragePrice
2001-01-02 num1
2001-01-03 num2
2001-01-04 num3
This is what I tried to do
df <- DataFrame %>%
group_by(DataFrame$Date) %>%
summarize(DataFrame$price == mean(DataFrame$Price))
and I got:
Error: Column `DataFrame$price == mean(DataFrame$Price)` must be length 1 (a summary value), not 0
Have not used the data.table library but would like to hear how it's possible there.