For example, I have 3 column:
Name Age Score:
Jason 21 98
Alice 19 67
Dave 36 89
John 28 70
I would like to plot x: Name and Y: Score, but I also want to sort X axis (names) by their Age.
Thanks so much for the help!
When using Graph Builder, all that has to be done, is to drag the variable you want to order your axis by, to the Order By area for the Axis, as shown below
Or you can sort the data table by the sort variable(Age), and then set the Column Property, Row Order Levels for the column Name, and then the order used for the Name variable axis will be the order the Names are found in the data table.
When using Graph Builder, all that has to be done, is to drag the variable you want to order your axis by, to the Order By area for the Axis, as shown below
Or you can sort the data table by the sort variable(Age), and then set the Column Property, Row Order Levels for the column Name, and then the order used for the Name variable axis will be the order the Names are found in the data table.
Thanks! It works!
I think the column property "Value Ordering" is what you need. It can be set manually using the column dialog or with jsl (example below).
// Example Table
New Table("test",
Add Rows(4),
New Column("Name",
Character,
Set Values({"Jason", "Alice", "Dave", "John"})
),
New Column("Age",
Set Values([21, 19, 36, 28])
),
New Column("Score:",
Set Values([98, 67, 89, 70])
)
);
// Plot Score by Age
Oneway(Y(:Name("Score:")), X(:Name));
// Set value ordering to Name after mean Age
Summarize( g = by( :Name ), m = Mean( :Age ) );
:Name << Set Property( "Value Ordering", Eval( g[Rank Index( m )] ) );
// Plot again!
Oneway(Y(:Name("Score:")), X(:Name));