Re: [R] Looping thorugh dataframe

2020-07-22 Thread William Dunlap via R-help
> library(dplyr, warn.conflicts=FALSE) > d <- data.frame(Company=c("MATH","IFUL","SSI","MATH","MATH","SSI"), > Turnover=c(2,3,5,7,9,11)) > d %>% group_by(Company) %>% summarize(Count=n(), MeanTurnover=mean(Turnover), > TotalTurnover=sum(Turnover)) `summarise()` ungrouping output (override with `.

Re: [R] Looping thorugh dataframe

2020-07-22 Thread Sarah Goslee
Hi, Your sample code suggests that you don't yet understand how R works, and might benefit from a tutorial or two. However, your verbal description of what you want is quite straightforward. Here's a R-style way to count the number of times each company appears, and to get the mean value of Turnov

Re: [R] Looping thorugh dataframe

2020-07-22 Thread e-mail ma015k3113 via R-help
Bert, thanks for responding to my email. I do realise that newbie's like my can expect curt answers but not to worry. I am definitely learning 'R' and what I posted are also statements from R. The statements run perfectly well but don't do what I want them to do. My mistake I have posted sample