I want to compare the cost of CPT codes from two different claim payers. Both have paired and non-rated service providers. I use dplyr and modeest::mlv , but it does not work as expected. Here are some sample data;
source CPTCode ParNonPar Key net_paid PaidFreq seq ABC 100 Y ABC100Y -341.00 6 1 ABC 100 Y ABC100Y 0.00 2 2 ABC 100 Y ABC100Y 341.00 6 3 XYZ 103 Y XYZ103Y 740.28 1 1 XYZ 104 N XYZ104N 0.00 2 1 XYZ 104 N XYZ104N 401.82 1 2 XYZ 104 N XYZ104N 726.18 1 3 XYZ 104 N XYZ104N 893.00 1 4 XYZ 104 N XYZ104N 928.20 2 5 XYZ 104 N XYZ104N 940.00 2 6
and code
str(data) View(data) ## Expand frequency count to individual observations n.times <- data$PaidAmounts dataObs <- data[rep(seq_len(nrow(data)), n.times),] ## Calculate mean for each CPTCode (for mode use modeest library) library(dplyr) library(modeest) dataSummary <- dataObs %>% group_by(ParNonPar, CPTCode) %>% summarise(mean = mean(net_paid), median=median(net_paid), mode = mlv(net_paid, method=mfv), total = sum(net_paid)) str(dataSummary)
I thought I could load the mode in the sum function with middle and middle, but this wording fixes an Error in as.character (x): cannot force type 'closure' to vector of type 'character' Without mlv, I get df like this, but I want to get all the statistics for the cpt payer on one line. I imagine a graphical display in the boxes, restricting the x and y segments as soon as I get what I need in the line
An inadequate answer is this (I forgot to get the payer name here!)
ParNonPar CPTCode mean median(net_paid) total N 0513F 0.000000 0.000 0.00 N 0518F 0.000000 0.000 0.00 N 10022 0.000000 0.000 0.00 N 10060 73.660000 90.120 294.64 N 10061 324.575000 340.500 1298.30 N 10081 312.000000 312.000 312.00 thanks very much for your time and effort.
source share