This week’s Friday Function is a utility that allows me to display the contents of a table in a window.
Here is the code used to create the above output:
1 2 3 4 5 6 7 8 9 10 11 12 |
dt = Open("$SAMPLE_DATA/Big Class.jmp"); content = H List Box( Bivariate( Y( :weight ), X( :height ), Fit Line, ), Outline Box("Data", <<Outline Close Orientation("Vertical"), Data Table To Table Box(dt) ) ); New Window("My Analysis",content); |
And here is the definition of the function Data Table To Table Box:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Data Table To Table Box = Function({dt},{Default Local}, tb = Table Box(); For (i=1,i<=NCols(dt),i++, col = Column(dt,i); colName = col << Get Name; lstValues = col << Get Values; type = col << Get Data Type; If (type=="Character", tb << Append( String Col Box(colName,lstValues) ) , tb << Append( Number Col Box(colName,lstValues) ) ); ); Return(tb); ); |
Hi David,
this elegant little snipped helped me a lot.
Thow an evil little trap lurcks within. If you write code for customers who have JMP installations in different languages on their systems, the code fails.
type = col << Get Data Type;
will give different results depending on the installed language. In German you will get "Zeichen" instead of "Character", so keep in mind to adjust the code accordingly.
Cheers
That is a very good point, it’s easy to forget variations in behaviour that may occur because of language settings.