2

I'm not sure how to pull the date from the data without the message:

" summarise() has grouped output by 'Id'. You can override using the .groups argument."

Below is the code I put in:

daily_activity_new<-daily_activity %>%
group_by(Id)%>%
summarise(Date_exersized=daily_activity$ActivityDate) 
  • 1
    This doesn't actually summarize anything, the results are effectively the same as `select(daily_activity, Id, Date_exersized = ActivityDate)` (as a `grouped_df` class object). What aggregation are you really hoping to effect? – r2evans May 04 '21 at 00:26
  • 1
    Can you show few lines of your input data and your expected output – akrun May 04 '21 at 00:50
  • (Especially with that much code, it is preferred to [edit] your question and put it there instead. Comments can easily be skipped by some readers, and when there are lots of comments, they can be hidden by the Stack interface. It's just best to keep the question itself as self-contained as possible. Thanks!) – r2evans May 04 '21 at 01:13
  • Definitely, thanks for letting me know. I will edit the question now – Trying to Learn Javascript May 04 '21 at 01:15
  • do you just want to remove the message? This post explains that https://stackoverflow.com/questions/62140483/how-to-interpret-dplyr-message-summarise-regrouping-output-by-x-override If there is something more that you want to do it would be easier to help if you create a small reproducible example along with expected output. Read about [how to give a reproducible example](http://stackoverflow.com/questions/5963269). – Ronak Shah May 04 '21 at 04:55

1 Answers1

2

We don't need the data$ inside the tidyverse. The daily_activity$ extracts the full column from the data instead of the values for each group 'Id'. It is not clear which function should be applied on the ActivityDate. If we need to return the min or first, apply that.

library(dplyr)
daily_activity %>%
    group_by(Id)%>%
    summarise(Date_exersized= min(ActivityDate), .groups = 'drop') 

Instead, if we want to create a new column, use mutate instead of summarise. The warning message is a friendly one. We can specify the .groups with one of the values i.e. 'drop' removes the group attribute. By default, it removes the last group

akrun
  • 874,273
  • 37
  • 540
  • 662