Re: [R] Help with R coding

2019-05-22 Thread Bill Poling
Thank you William appreciate your response Sir. WHP From: William Michels Sent: Wednesday, May 22, 2019 9:58 AM To: Bill Poling Cc: r-help (r-help@r-project.org) Subject: Re: [R] Help with R coding Morning Bill, I take it this is dplyr? You might try: tmp1 <- HCPC %>% group_by(HCP

Re: [R] Help with R coding

2019-05-22 Thread Bill Poling
Thank you Jeff! WHP From: Jeff Newmiller Sent: Wednesday, May 22, 2019 10:06 AM To: r-help@r-project.org; Rui Barradas ; Bill Poling ; r-help (r-help@r-project.org) Subject: Re: [R] Help with R coding Generally more efficient to filter before grouping. Note that summarize clears out

Re: [R] Help with R coding

2019-05-22 Thread Jeff Newmiller
Generally more efficient to filter before grouping. Note that summarize clears out whatever isn't mentioned in it, so the subsetting currently being done in the mean call could also be done in the pre-filter step and you can avoid filtering other columns and then discarding them by limiting the

Re: [R] Help with R coding

2019-05-22 Thread William Michels via R-help
Morning Bill, I take it this is dplyr? You might try: tmp1 <- HCPC %>% group_by(HCPCSCode) %>% summarise(Avg_AllowByLimit = mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0 & AllowByLimitFlag == TRUE)])) The code above gives "NaN" for cases where AllowByLimitFlag == FALSE. Maybe this is the answer

Re: [R] Help with R coding

2019-05-22 Thread Bill Poling
Zelis Healthcare -Original Message- From: Rui Barradas Sent: Wednesday, May 22, 2019 9:46 AM To: Bill Poling ; r-help (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(HC

Re: [R] Help with R coding

2019-05-22 Thread Rui Barradas
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