// For a contingency table report, swap the x and y
// currently can swap the mosaic plot only
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
myr = Contingency( Y( :Age ), X( :sex ) );
// Have to have a Contingency Analysis report open
// Can add test to make sure it is open in the future
myr = Current Report();
// taking apart CrossTabBox was easier using XML than JSL
mys = myr["Contingency Table"][CrossTabBox(1)] << Get XML;
// get current X role or rows of contingency table
start = Contains(mys,"<CROSSTABBOXROWSLABEL>")+22;
end = Contains(mys,"</CROSSTABBOXROWSLABEL>");
newY = Substr(mys,start,end-start);
// get current Y role or cols of contingency table
start = Contains(mys,"<CROSSTABBOXCOLSLABEL>")+22;
end = Contains(mys,"</CROSSTABBOXCOLSLABEL>");
newX = Substr(mys,start,end-start);
// Recreate same contingency table but with X and Y flipped
// also temporarily use Value Order to match the Mosaic Plot
myValueLabels = Reverse(Associative Array(Column(dt,newX)) << Get Keys);
Column(dt,newX) << Set Property("Value Ordering",myValueLabels);
tempCont = Contingency( Y(Column(dt,newY) ), X(Column(dt,newX) ), Contingency Table );
tempContr = tempCont << Report;
mycopy = tempContr["Contingency Table"][CrossTabBox(1)] << Clone Box;
tempCont << Close Window;
Column(dt,newX) << Delete Property("Value Ordering");
// remove the original contingency table and replace with transpose
myr["Contingency Table"][CrossTabBox(1)] << Delete;
myr["Contingency Table"] << Append(mycopy);
// show original side by side
obj = Contingency( Y( :Age ), X( :sex ) );
Report(obj)["Contingency Table"] << Set Title("Contingency Table - Current output");
myr["Contingency Table"] << Set Title("Contingency Table - Wish List for JMP15");是否还有其他人对列联表和马赛克情节的方向感到困扰?我不使用它,但我们的一个JMP用户想要翻转表格的方向,使其与马赛克图表相匹配。发现如果你交换X和Y,表格和马赛克图都会更新。请参阅下面的脚本以运行示例并将它们并排比较。您似乎希望表格中的数字与马赛克图中的单元格对齐,以便于查看和参考。我找不到任何先前的讨论。似乎偶然表不能改变,它是一个CrossTabBox,它不适合改变任何东西。下面的脚本在顶部有解决方法,即在切换x和y时复制表格,然后将其附加到马赛克图表中。还必须通过Value Ordering做一点才能让它排成一行。将添加到JMP15愿望清单。我在EA实验室和开发人员的JMP Discovery Summit上进行了讨论。
在R语言上找到一些帖子,你可以使用dir()参数并指定水平和垂直,而RStudio中的“count”输出对于方向保持相同。
#R马赛克图示例 - 改变方向
getwd()
employee < - read.csv(“Products.csv”,TRUE,sep =“,”,
na.strings = TRUE)
count < - table(employee $ EnglishCountryRegionName,
员工$颜色)
计数
mosaicplot(count,main =“国家马赛克图”,
sub =“按国家/地区划分的产品颜色”,
xlab =“颜色”,
ylab =“国家”,
las = 1,
dir = c(“h”,“v”),
color =“skyblue2”,
border =“chocolate”)