r - Processing Data Set Split Twice using Apply() Function(s) -


i attempting create process capability charts/data using qcc package in r, , our facility quality data. data set includes 250,000 records constructed. data set has 3 columns: "erpkey", "altworkinstruction", "testvalue". have second data frame houses specification info: "erpkey", "altworkinstruction", "lsl", "target", "usl".

my goal 3 things:

1.) using library("outliers") package, use rm.outliers remove erronious data data set, "erpkey" , "altworkinstruction".

2.) use sqldf load correct specification info use in library("qcc") package.

3.) create output using process.capability() library("qcc") using following 2 statements:

tmp <- qcc(data.set, type = "xbar.one", nsigmas = 3, plot = true) process.capability(tmp, spec.limits = c(lslindividual, uslindividual), target = targetindividual) 

i'm interested in getting plots report. i'll create tables summary statistics later.

i've attempted spliting data.set twice, once "altworkinstruction" field, using lapply split each object in list "erpkey", attempting structure actual work of creating process.capability plot. i've not been able syntax correct , unfamiliar more complex cases in apply() family, thought opportunity assistance , learn something. split() correct way go this, or there way nest tapply statements achieve this? i'm open suggestions. partial code below:

specifications <- as.data.frame(sqlquery(conn, paste("query"))) data.set <- as.data.frame(sqlquery(conn, paste("query2"))) data.set.split <- split(data.set, data.set$altworkinstruction, drop = true)  test <- lapply(lapply(data.set.split, function(x) split(x, x$erpkey)), function(x,y) {   x$y$testvalue <- rm.outlier(as.data.frame(x$y$testvalue), fill = false)   spec <- sqldf(paste("select * specifications altworkinstruction = '", x, "' , erpkey = '", y, "'", sep = ""))   lslindividual <- spec$lslindividual[1]   targetindividual <- spec$targetindividual[1]   uslindividual <- spec$uslindividual[1]   tmp <- qcc(x$y$testvalue, type = "xbar.one", nsigmas = 3, plot = true)   return(process.capability(tmp, spec.limits = c(lslindividual, uslindividual), target = targetindividual)) }) 

thanks help!


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -