我有一个数据集,其中包含许多连续的数据列和我在仪表板中过滤的两个分类因素,以及一个用于拆分所有图表/分析的附加分类变量(组)。 我还有一个主列切换器,这意味着用户可以循环浏览每个连续变量的汇总表。 主列切换器链接到仪表板内绘图和分析上的所有其他列切换器。 因此,任何绘图和分析一次都显示一个连续变量,并且可以按性别(男性/女性或两者)过滤。
这一切都很好,但是当我创建一个新表 (dtSumm) 时出现问题,该表使用每个连续变量的汇总统计表并计算一个新变量(相对变化)。 这个新的汇总表只有与组类别一样多的行,并且没有性别,所以我们现在无法通过它进行过滤。
dtSumm的代码如下:
// Create a separate datatable for treatment group means
dtSumm = dt << Summary (
Group (:Group,:Sex ),
Mean ( eval ( cols ) ),
statistics column name format( "column" ),
Link to original data table( 1 ),
invisible
);
// Add RC columns for each column in cols to dtSumm
//This works by getting the mean of each column for treatment group "A"
For( i = 1, i <= num, i++,
mean0 = Mean(Column(cols[i])[(dtSumm << get rows where( :"Group" == "A"))]);
dtSumm << New Column(
Char(cols[i]||"_RC"),
Formula( ( ( ( column( cols[i] )[]) - ( eval(mean0) ) ) / ( eval(mean0) ) ) * 100 )
);
);
欢迎任何建议。 谢谢
现在可能有更好的方法,但过去我使用过“makeFilterChangeHandler()”。 所以,概括地说:
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Report involving detail-level data
NewWindow("Detail and Summary Data with Local Data Filter", << onClose(Try(Close(dt2, noSave))),
hlb = HListBox(dist = dt << Distribution(Continuous Distribution( Column( :height ) )));
);
// Local data filter
ldf = dist << Local Data Filter( Add Filter( columns( :sex ) ) );
// This script will run each time the filter selection is changed
ldfChange =
Function( {a},
filteredRows = ldf << getFilteredRows;
// Try to close any open ancilary tables
Try(Close(dt2, noSave));
// Make a subset table according to the current selection
dt2 = dt << subset(Rows(filteredRows), Invisible);
// Aggregate the subset table
dt3 = dt2 << summary(Mean(:height), Invisible);
// Update the report
hlb << append(dt3 << Tabulate(Show Control Panel( 0 ), Add Table(Column Table( Analysis Columns( :"Mean(height)"n ), Statistics( Mean ) ))));
);
// Attach the script to the local data filter
rsh = ldf << makeFilterChangeHandler(ldfChange);添加一个示例来演示问题可能会有所帮助。 (见下面的 JSL)
该示例使用来自 JMP 样本数据的 AdverseR 数据。 目标是生成这样的仪表板:

您可以看到 SEX 上有一个数据过滤器。 并且有一个列切换器可以切换在两个 Tabulate 报告和 Distribution 中汇总的“响应”变量。
第一个制表(左)给出了每个治疗组的平均反应。
第二个制表(右)给出了每个治疗组相对于 PBO 组的平均响应变化百分比。 这从每个治疗组的每个响应的平均值的汇总表(“dtSumm”)运行。
问题是数据过滤器适用于除第二个 Tabulate 报告之外的所有内容。 如果 dtSumm 可以仅汇总满足 Data Filer 标准的数据,那将是理想的。 当数据过滤器中的选择发生变化时,将重新创建 dtSumm。
那可能吗?
// Open the data table
dt = Open( "$SAMPLE_DATA/AdverseR.jmp" );
//Define cols as the list of columns for column switcher to use
//This is essentially hard-coding the columns that will be used in the dashboard
//Edit the items in this list to change the columns used in the dashboard
cols = {"DAY ON DRUG", "AGE", "WEIGHT", "ADR DURATION"};
//Define num as the number of columns in the list, cols
num = length(cols);
// We create a separate data table for treatment group means
// Get table, dtSumm, of means by group for each column in cols
dtSumm = dt << Summary (
Group (:Name("TREATMENT GROUP")),
Mean ( eval( cols ) ),
statistics column name format( "column" ),
Link to original data table( 1 ),
invisible
);
// Add RC columns for each column in cols to dtSumm
//This works by getting the mean for "PBO" treatment group for each
For( i = 1, i <= num, i++,
mean0 = Mean(Column(cols[i])[(dtSumm << get rows where( :"TREATMENT GROUP" == "PBO"))]);
dtSumm << New Column(
Char(cols[i]||"_RC"),
Formula( ( ( ( column( cols[i] )[]) - ( eval(mean0) ) ) / ( eval(mean0) ) ) * 100 )
);
);
// Create dashboard with tables and Distribution plot
mainWindow=New Window( "Example",
H List Box(
dt << Current Data Table() << Data Filter(
Location( {55, 48} ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) ),
Add Filter( columns( :SEX ) ) //
);
,
table1= dt << Tabulate(
Show Control Panel( 0 ),
Add Table(
Column Table(
Analysis Columns(
Column( cols[1] )
),
Statistics( Mean, N )
),
Row Table( Grouping Columns( :TREATMENT GROUP ) )
)
);
,
table2= dtSumm << Tabulate(
Change Item Label( Statistics( Mean, "%Rel Change" ) ),//Changes heading from "Mean"
Show Control Panel( 0 ),
Add Table(
Column Table( Analysis Columns( Char(cols[1]||"_RC") ), Statistics( Mean ) ),
Row Table( Grouping Columns( :TREATMENT GROUP ) )
)
);
,
dist0 = dt << Distribution(
Continuous Distribution(
Column( cols[1] ), //dt_c_col[1] uses first in column list
Always use column properties( 1 ),
Process Capability( 0 )
),
Histograms Only,
SendToReport(
Dispatch( {}, "Distribution", OutlineBox ),
Dispatch( {}, "Process 1", OutlineBox, {Close( 1 )} )
)
)
)
);
// Add a column switcher to table1
cs = table1 << Column Switcher(
cols[1],
cols
);
// Link column switchers at each platform - JMP 15 solution
cs1 = table2 << Column Switcher(
Char(cols[1]||"_RC"),
eval list(dtSumm << Get Column Names( String ))[(num+3)::(num+2+num)],
Close Outline( 1 )
);
cs2 = dist0 << Column Switcher(
cols[1],
cols,
Close Outline( 1 )
);
mainWindow[ListBoxBox( 1 )] << Set Script(
var = mainWindow[ListBoxBox( 1 )] << Get Selected;
cs1 << Set Current(Char(var[1]||"_RC"));
cs2 << Set Current(var[1]);
);