- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Extract and exclude
Hi,
I'm trying to select all of the rows with the value of 1 in the Violation column, extract the Device column value, then exclude all of the rows associate with those devices. Anyone can help me coming up with a script? Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract and exclude
Below is a script which will perform this action
Names Default To Here(1);
dt = Current Data Table();
dt << Clear Row States;
violation_rows = dt << Get Rows Where(:Violation == 1);
violation_devices = Associative Array(dt[violation_rows, "Device"]) << get keys;
dt << Select Where(Contains(violation_devices, :Device)) << Exclude(1) << Clear Select;
- Get row numbers where :Violation == 1
- Use Data table subscripting and associative array to get the devices
- Select rows with those devices and exclude them
You can easily also do this interactively (and this will be recorded by enhanced log):
- Create a summary table with Device as Group and Violation as subgroup. Also make sure the tables are linked
- Select 0 values from N(1) (indicates where Validation == 1) and then right click on rows to invert selection
- Now you have the devices selected in your main table
- You can now exclude these rows
JMP will create you a script like this
// Open Data Table: Sample(1).jmp
// → Data Table("Sample(1)")
Open("$DOWNLOADS/Sample(1).jmp");
// Data table summary
// → Data Table("Sample(1) By (Device)")
Data Table("Sample(1)") << Summary(Group(:Device), N, Subgroup(:Violation), Freq("None"), Weight("None"));
// Select matching cells
Data Table("Sample(1) By (Device)") << Select Where(:"N(1)"n == 0);
// Invert current selection
Data Table("Sample(1) By (Device)") << Invert Row Selection;
// Toggle selected rows' exclude state
Data Table("Sample(1) By (Device)") << Select Where(:"N(1)"n == 0) << Invert Row Selection << Exclude;
// Close Data Table: Sample(1) By (Device)
Close(Data Table("Sample(1) By (Device)"), NoSave);
and with some small modifications it will be fairly robust script be used in the future (use variables instead of table names, start it with Names Default To Here(1)... to mention some changes).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract and exclude
Below is a script which will perform this action
Names Default To Here(1);
dt = Current Data Table();
dt << Clear Row States;
violation_rows = dt << Get Rows Where(:Violation == 1);
violation_devices = Associative Array(dt[violation_rows, "Device"]) << get keys;
dt << Select Where(Contains(violation_devices, :Device)) << Exclude(1) << Clear Select;
- Get row numbers where :Violation == 1
- Use Data table subscripting and associative array to get the devices
- Select rows with those devices and exclude them
You can easily also do this interactively (and this will be recorded by enhanced log):
- Create a summary table with Device as Group and Violation as subgroup. Also make sure the tables are linked
- Select 0 values from N(1) (indicates where Validation == 1) and then right click on rows to invert selection
- Now you have the devices selected in your main table
- You can now exclude these rows
JMP will create you a script like this
// Open Data Table: Sample(1).jmp
// → Data Table("Sample(1)")
Open("$DOWNLOADS/Sample(1).jmp");
// Data table summary
// → Data Table("Sample(1) By (Device)")
Data Table("Sample(1)") << Summary(Group(:Device), N, Subgroup(:Violation), Freq("None"), Weight("None"));
// Select matching cells
Data Table("Sample(1) By (Device)") << Select Where(:"N(1)"n == 0);
// Invert current selection
Data Table("Sample(1) By (Device)") << Invert Row Selection;
// Toggle selected rows' exclude state
Data Table("Sample(1) By (Device)") << Select Where(:"N(1)"n == 0) << Invert Row Selection << Exclude;
// Close Data Table: Sample(1) By (Device)
Close(Data Table("Sample(1) By (Device)"), NoSave);
and with some small modifications it will be fairly robust script be used in the future (use variables instead of table names, start it with Names Default To Here(1)... to mention some changes).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Extract and exclude
Thank you for the prompt reply. You have just made my day!