I have 2 years of daily data That I would like to subset into Date Quarters for example, Jan, Feb, Mar = Q1_2019, Apl, May, Jun=Q2_2019, etc.
I have Already Created a Summary data that has compiled the data into Months. This is the Code I used:
Summary_dates <- mydata %>% group_by(month = lubridate::floor_date(newDate, 'month'),Provider)%>% summarise(avg_steps = mean(Steps), avg_TEE=mean(TEE), avg_activity_min=mean(total_activity_min))
From here I tried Creating my first subset
Q1_2019 <- data[Summary_dates$month >= "2019-01-01" & Summary_dates$month <= "2019-03-01", ]
But I Keep receiveing an error code:
Error in data[Summary_dates$month >= "2019-01-01" & Summary_dates$month <= :
object of type 'closure' is not subsettable
After My quarter subsets are created, I want to create a new Dataframe with all the Quarters so I can make a Graph Comparing each quarter to each other.
Here is a Glimpse of mydata :
glimpse(mydata)
Rows: 72,001
Columns: 12
$ ID <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
$ Steps <dbl> 1208, 6784, 6470, 10042, 6301, 9619, 7844, 5718, 6620, 6033, 6337, 4917, 10586, 9199, 96…
$ TEE <dbl> 2375, 2713, 2685, 2817, 4289, 3405, 3097, 3902, 2810, 2774, 2574, 2841, 3552, 2892, 3233…
$ AEE <dbl> 72, 410, 382, 514, 1986, 1102, 794, 1599, 507, 471, 271, 538, 1249, 589, 930, 263, 1291,…
$ Sedentary <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ LPA <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ MPA <dbl> 10, 0, 0, 0, 21, 7, 38, 33, 6, 26, 0, 40, 43, 19, 42, 0, 62, 47, 138, 63, 0, 0, 0, 15, 1…
$ VPA <dbl> 0, 0, 0, 0, 137, 6, 6, 106, 6, 5, 0, 3, 51, 0, 23, 0, 12, 60, 86, 34, 0, 0, 0, 13, 1, 0,…
$ NonWear <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ Provider <chr> "Garmin", "Garmin", "Garmin", "Garmin", "Garmin", "Garmin", "Garmin", "Garmin", "Garmin"…
$ newDate <date> 2019-09-03, 2019-09-04, 2019-09-05, 2019-09-06, 2019-09-07, 2019-09-08, 2019-09-09, 201…
$ total_activity_min <dbl> 10, 0, 0, 0, 158, 13, 44, 139, 12, 31, 0, 43, 94, 19, 65, 0, 74, 107, 224, 97, 0, 0, 0, …