I currently have a script that creates control and process capability charts for a variety of variables, puts it in a journal, and then saves the journal as a pdf. The problem is, my script is 5000 lines long and runs slower than molasses in a freezer. So I thought it would make more sense to define a function for each type of chart that I build and stitch them together that way. I successfully created functions for the control charts, but I can't get the process capability chart to work.
Here is a script that uses the Airport sample data (attached) to create a chart that looks like the one I'm trying to make:
Process Capability(
Process Variables( :Flight ), // select column for data
Spec Limits( :Flight( LSL( 0 ), /*Target( 30 ),*/ USL( 20 ) ) ), //Spec limits, dont need target
Individual Detail Reports( 1 ),
Capability Box Plots( 0 ),
Goal Plot( 0 ),
Capability Index Plot( 0 ),
Process Performance Plot( 0 ), // hide unnecessary info
{:Flight << Process Capability Analysis(
Overall Sigma Capability( 1 ),
Within Sigma Capability( 1 ),
Histogram( 1, Show Target( 1 ), Show Within Sigma Density( 1 ), Show Overall Sigma Density( 1 ) )
)},
);I would like to define a function with the column name as an input. Here is what I have so far:
capability_chart = function({variable, low, up},
Process Capability(
Process Variables( eval(variable) ), // select column for data
Spec Limits( eval(variable)(LSL( low ), /*Target( 30 ),*/ USL( up )) ),
Individual Detail Reports( 1 ),
Capability Box Plots( 0 ),
Goal Plot( 0 ),
Capability Index Plot( 0 ),
Process Performance Plot( 0 ), // hide unnecessary info
{column(dt, element) << Process Capability Analysis(
Overall Sigma Capability( 1 ),
Within Sigma Capability( 1 ),
Histogram( 1, Show Target( 1 ), Show Within Sigma Density( 1 ), Show Overall Sigma Density( 1 ) )
)}
)
);
capability_chart("Flight", 0, 10)When I run this, a window pops up prompting me for spec limits. I want my script to automatically populate spec limits. I've also tried using column() and ascolumn() instead of eval() in the spec limits line but they did the same thing. Ideally, I wouldn't have to create a spec table or add spec limits as a column property but I can do that if there isn't another way. I also don't want to loop through all the columns and create a bunch of process capability charts because there's an existing format for the report that would be confusing to change. Any help is appreciated.