In R,using dplyr package, I tried the function "summarise" and I expect the result to show along with the groupby field. However, all of a sudden I see summarized output but without the groupby filed which makes the results meaningless. Any one any idea?

For example if data has ages and salaries for members belonging to a team and I try to view the Average Age and Salary by Team the code below returns just the averages without the team names

df_summ = df %>% group_by(Team)%>% summarise(AvgAge= mean(Age),AvgSalary= mean(Salary)) 

So without the groupby column "Team" the result is meaningless

What Am I missing here?

  • 1
    $\begingroup$ Make sure package ‘plyr’ wasn’t loaded first. ‘Summarize’ is overloaded if plyr is loaded first and it doesn’t yield the same result $\endgroup$ – HEITZ May 8 '18 at 22:09
  • $\begingroup$ It sure was something to do with the version of the package dplyr. I noticed that my R server had 3 versions of dplyr sitting in packages .... clicking and Un-clicking a few versions of dplyr did the job and then I could see the groupby field appear again.... Thank you HEITZ For your reply $\endgroup$ – snehal sharma May 9 '18 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.