- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Custom function with varying number of input columns?
Hi,
is it possible to define a custom function which works for 2-5 selected columns?
Add Custom Functions(
New Custom Function(
"custom",
"concat",
Function( {col1, col2, col3=., col4=., col5=.},
If(not (is missing(col 4)),
Char(col1) || "_" || Char(col2)|| "_" || Char(col3)|| "_" || Char(col4)|| "_" || Char(col5),
not (is missing(col 4)),
Char(col1) || "_" || Char(col2)|| "_" || Char(col3)|| "_" || Char(col4),
not (is missing(col 3)),
Char(col1) || "_" || Char(col2)|| "_" || Char(col3),
not (is missing(col 4)),
Char(col1) || "_" || Char(col2))
),
<<Transform Category( 1 ),
<<Description( "combine 2-5 columns with underscore" ),
<<Example(
Expr(
Show( custom:concat( :height, :weight, :sex, :age, :name ) );
)
)
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Custom function with varying number of input columns?
How about passing the columns in as a list? That way there's only one argument, and it can have as many columns as you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Custom function with varying number of input columns?
I suffer from the missing concatenate entry in the right click / new formula column menu.
I want to create my own function.
I guess the custom function can just be used for transforms if the columns are listed individually.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Custom function with varying number of input columns?
Concatenate is there in JMP 18.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Custom function with varying number of input columns?
Unfortunately, NOT in general.
Yes, there is such a function.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Formula Column(
Operation( Category( "Character" ), "Concatenate with Underscore" ),
Columns( :height, :weight )
);
It appears in the right-click new formula column menu if at least one of the columns is a character column.
Unfortunately, the setting disappears if all columns are numeric : (
Until now, we used a special shortcut icon in a toolbar.
A few days ago, one of my colleagues asked why there is no such possibility via the right-click new formula column.
So close - but for many cases: not accessible via the GUI.