OK, is there an easy general way to use wild card in jmp scripting? I need to list all columns that start with 'Row' (like Row1 Row2 Row3...) in COLUMN COMBINE commend. Thanks.
Don't know. This works for me.
Names default to here(1);
dt = New Table( "Untitled 231",
Add Rows( 1 ),
New Column( "ID", Set Values( [1] )),
New Column( "Row1", character, Set Values( {"a"} )),
New Column( "Row2", character, Set Values( {"b"} )),
New Column( "Row3", character, Set Values( {"c"} )),
New Column( "Row4", character, Set Values( {"d"} )),
New Column( "Row5", character, Set Values( {"e"} )),
);
partial_column = function({searchtxt, dt=currentdatatable()},
{default local},
allCols = dt << GetColumnNames("String");
filtered_list = {};
for(i=1, i<=nitems(allCols), i++,
if(isstring(regex(allCols[i], searchtxt)),
insert into(filtered_list, allCols[i]);
);
);
return(filtered_list);
);
dt << Combine Columns(
Columns(partial_column("Row.")),
Column Name( "ALL" ),
Delimiter( " " )
);
You can wildcard, but it will only get the first.
dt = open("$SAMPLE_DATA\Big Class.jmp");
Column(dt, "?eight"); //Column( "height" )
it's an easy enough loop though
partial_column = function({searchtxt, dt=currentdatatable()},
{default local},
allCols = dt << GetColumnNames("String");
filtered_list = {};
for(i=1, i<=nitems(allCols), i++,
if(isstring(regex(allCols[i], searchtxt)),
insert into(filtered_list, allCols[i]);
);
);
return(filtered_list);
);
partial_column(".eight"); // {"height", "weight"}
I want to combine Row1 to Row5 (i want it automate since i may have Row100 in real dataset), and I cannot just wild card like this? If I add the loop, not sure where to put it.
EG Dataset;
ID Row1 Row2 Row3 Row4 Row5 ALL
1 a b c d e a b c d e
My code:
Data Table( "Transpose of stack sort") <<
Combine Columns(
partial_column("Row?"),
Column Name( "ALL" ),
Delimiter( " " )
);
Two things, you need to put Columns() around your columns, and wildcards for regex is "."
So you probably need to do something like this
Data Table( "Transpose of stack sort") <<
Combine Columns(
Columns(partial_column("Row.")),
Column Name( "ALL" ),
Delimiter( " " )
);
This sounds the solution, but I got this error when I run it.
Don't know. This works for me.
Names default to here(1);
dt = New Table( "Untitled 231",
Add Rows( 1 ),
New Column( "ID", Set Values( [1] )),
New Column( "Row1", character, Set Values( {"a"} )),
New Column( "Row2", character, Set Values( {"b"} )),
New Column( "Row3", character, Set Values( {"c"} )),
New Column( "Row4", character, Set Values( {"d"} )),
New Column( "Row5", character, Set Values( {"e"} )),
);
partial_column = function({searchtxt, dt=currentdatatable()},
{default local},
allCols = dt << GetColumnNames("String");
filtered_list = {};
for(i=1, i<=nitems(allCols), i++,
if(isstring(regex(allCols[i], searchtxt)),
insert into(filtered_list, allCols[i]);
);
);
return(filtered_list);
);
dt << Combine Columns(
Columns(partial_column("Row.")),
Column Name( "ALL" ),
Delimiter( " " )
);
You might be able to use JMP Patterns for this task.