Viens veids, kā to paveikt ir izmantot "rxDataStep" un 'piedēvēt' funkciju R pakotnes "Hmisc".
Šeit ir dažas koda paraugu R un piedēvēt vidējās izmaksas uz vienu prasības:car.insurance.df <- data.frame(AgeLevel=factor(c(rep("17-20",4), rep("21-24",4),rep("25-29",4),rep("30-34",4),
rep("35-39",4),rep("40-49",4),rep("50-59",4), rep("60+",4))), Car.group = factor(rep(c("A","B","C","D"),8)), Veh.Age=factor(rep(c(rep("0-3",4),rep("4-7",4),rep("8-9",4), rep("10+",4)),2)), AvgCost.claim = c(289,372,189,763,282,249,288,850,133,288,179, NA,160,11,NA,NA,302,420,268,407,194,243,343,320,135,196,293,205,166,135,104,NA), claims.weights = c(8,10,9,3,8,28,13,2,4,1,1,0,1,1,0,0,18,59,44,24,31,96,39,18,10,13,7,2,4,3,2,0)) rxDataFrameToXdf(data = car.insurance.df, outFile = "car.insurance.xdf") install.packages("Hmisc") library(Hmisc) rxDataStep(inData = "car.insurance.xdf", outFile = "car.insurance-imputed.xdf", transforms = list(AvgCost.claim.New = impute(AvgCost.claim)), transformPackages = "Hmisc") rxSummary(~Car.group + AvgCost.claim, data = "car.insurance-imputed.xdf", fweights ="claims.weights")