Thank you Rui, but that is getting me the overall mean not the mean of just the 
observations that are flagged as TRUE Grouped By the HCPCSCode
 (AllowByLimitFlag == TRUE).

I also tried adding it to the filter you suggested but that does not seem to 
work either?

tmp1 <- tmp %>%
  group_by(HCPCSCode) %>%
  filter(AllowByLimitFlag==TRUE) %>%
  summarise(Avg_AllowByLimit =
              mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))

However, I really appreciate your help Sir!

WHP


William H. Poling, Ph.D., MPH | Manager, Data Science
Data Intelligence & Analytics
Zelis Healthcare


-----Original Message-----
From: Rui Barradas <ruipbarra...@sapo.pt>
Sent: Wednesday, May 22, 2019 9:46 AM
To: Bill Poling <bill.pol...@zelis.com>; r-help (r-help@r-project.org) 
<r-help@r-project.org>
Subject: Re: [R] Help with R coding

Hello,

Maybe filter the AllowByLimitFlag values first (not tested)?


tmp1 <- tmp %>%
   group_by(HCPCSCode) %>%
   filter(AllowByLimitFlag) %>%
   summarise(Avg_AllowByLimit =
mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))


Hope this helps,

Rui Barradas


Às 13:35 de 22/05/19, Bill Poling escreveu:
> tmp1 <- tmp %>%
> group_by(HCPCSCode) %>%
> summarise(Avg_AllowByLimit = 
> mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))
>
> # But I need Something like that + This
>
> WHERE AllowByLimitFlag == TRUE


Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, or taking any action in reliance on the contents of this transmission 
is strictly prohibited. If you have received this transmission in error, please 
contact the sender immediately. Zelis, 2018.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to