- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How do i extract the number of levels from a distribution
Hi all,
I would like to get a JMP Script that allows me to extract the value that i highlighted in the red box and to put it into a column of a new table. PS: I know that it is possible to generate a table from the distribution with the command Make into Data Table but this command does not work on the number in the box.
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do i extract the number of levels from a distribution
Created:
Sep 4, 2024 06:46 AM
| Last Modified: Sep 4, 2024 3:58 AM
(601 views)
| Posted in reply to message from ConstructHorse2 09-04-2024
Here is an example of one way to do this
names default to here(1);
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
summarize( dt, levels = By( :Age ) );
dtNew = New Table( "Count",
Add Rows( 1 ),
New Column( "Count" )
);
dtNew:Count[1] = N Items( Levels );
Here is a second example that reads the Frequencies table directly and count the number of rows
names default to here(1);
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
// Report snapshot: Big Class - Distribution of sex
dis = Data Table( "Big Class" ) << Distribution( Nominal Distribution( Column( :age ) ) );
dtNew = New Table( "Count2",
Add Rows( 1 ),
New Column( "Count" )
);
// Calculate the number of items in the Frequencies table, minus the
// the last row which is the Totals row
tableLevels = N Items( report(dis)["Frequencies",StringColBox(1)] << get ) - 1;
dtNew:Count[1] = tableLevels;
Jim
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do i extract the number of levels from a distribution
Created:
Sep 4, 2024 06:46 AM
| Last Modified: Sep 4, 2024 3:58 AM
(602 views)
| Posted in reply to message from ConstructHorse2 09-04-2024
Here is an example of one way to do this
names default to here(1);
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
summarize( dt, levels = By( :Age ) );
dtNew = New Table( "Count",
Add Rows( 1 ),
New Column( "Count" )
);
dtNew:Count[1] = N Items( Levels );
Here is a second example that reads the Frequencies table directly and count the number of rows
names default to here(1);
dt =
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );
// Report snapshot: Big Class - Distribution of sex
dis = Data Table( "Big Class" ) << Distribution( Nominal Distribution( Column( :age ) ) );
dtNew = New Table( "Count2",
Add Rows( 1 ),
New Column( "Count" )
);
// Calculate the number of items in the Frequencies table, minus the
// the last row which is the Totals row
tableLevels = N Items( report(dis)["Frequencies",StringColBox(1)] << get ) - 1;
dtNew:Count[1] = tableLevels;
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do i extract the number of levels from a distribution
After my question I managed to write the code with method two on my own but method one seems more convenient and immediate. Thank you!