Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Re: Arrange in rows by group

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jul 10, 2018 6:09 PM
(3502 views)

Hi,

Here is the problem I am trying to solve:

6 Y continuous variables (Y1,Y2,..Y6), same continuous X variable (1) and sample ID field (SID).

I am doing a BiVariate fit grouping by SID. I would like all 6 plots to be in a row and with each SID group.

SID=1

Y1,Y2,Y3,Y4,Y5,Y6,

SID=2

Y1,Y2,Y3,Y4,Y5,Y6,

......

How would I script this? The Y's and X are know and fixed while the number of sample IDs will vary.

Andy

3 ACCEPTED SOLUTIONS

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Here is an example script using a methodlogy I have used many times, that I think produces the results you want.

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
// Setup data to look somewhat like your data
dt << delete columns( 1, 2, 3 );
Column( dt, 1 ) << set name( "SID" );
Column( dt, 2 ) << set name( "X" );
Column( dt, 3 ) << set name( "Y1" );
Column( dt, 4 ) << set name( "Y2" );
Column( dt, 5 ) << set name( "Y3" );
Column( dt, 6 ) << set name( "Y4" );
Column( dt, 7 ) << set name( "Y5" );
Column( dt, 8 ) << set name( "Y6" );
dt << delete columns( Index( 9, 129 ) );
// Determine the number of SIDs
Summarize( dt, SIDgrps = by( SID ) );
// Create the output window
nw = New Window( "Report", MainVLB = V List Box() );
// Create a list to hold the data table names
dtList = {};
// Setup what to do when the display window is closed
nw << on close( For( i = 1, i <= N Items( SIDgrps ), i++, Close( dtList[i], nosave ) ) );
// Loop through the SIDs and generate the required reports
For( i = 1, i <= N Items( SIDgrps ), i++,
dt << select where( :SID == Num( SIDgrps[i] ) );
dtSub = dt << subset( selected rows( 1 ), selected columns( 0 ), invisible );
Insert Into( dtList, dtSub );
dtSub << set name( "SID=" || SIDgrps[i] );
ob = Outline Box( "SID=" || SIDgrps[i],
H List Box(
dtSub = Bivariate( Y( :Y1 ), X( :X ) ),
dtSub = Bivariate( Y( :Y2 ), X( :X ) ),
dtSub = Bivariate( Y( :Y3 ), X( :X ) ),
dtSub = Bivariate( Y( :Y4 ), X( :X ) ),
dtSub = Bivariate( Y( :Y5 ), X( :X ) ),
dtSub = Bivariate( Y( :Y6 ), X( :X ) ),
)
);
// Add the current set of reports to the main display
MainVLB << append( ob );
);
```

Jim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

From your description, it seems like all you have to do is use SID in the By role.

```
Bivariate(
Y( :Y1, :Y2, :Y3, :Y4, :Y5, :Y6 ),
X( :X ),
By( :SID )
);
```

Learn it once, use it forever!

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I think this way might be simpler and give you the layout you want:

```
New Window( "Fitness - Bivariate",
V List Box(
Fit Group(
Bivariate( Y( :Age ), X( :MaxPulse ) ),
Bivariate( Y( :Weight ), X( :MaxPulse ) ),
Bivariate( Y( :Oxy ), X( :MaxPulse ) ),
Bivariate( Y( :Runtime ), X( :MaxPulse ) ),
Bivariate( Y( :RunPulse ), X( :MaxPulse ) ),
Bivariate( Y( :RstPulse ), X( :MaxPulse ) ),
<<{Arrange in Rows( 2 )},
By( :Sex )
),
Fit Group(
Bivariate( Y( :Age ), X( :MaxPulse ) ),
Bivariate( Y( :Weight ), X( :MaxPulse ) ),
Bivariate( Y( :Oxy ), X( :MaxPulse ) ),
Bivariate( Y( :Runtime ), X( :MaxPulse ) ),
Bivariate( Y( :RunPulse ), X( :MaxPulse ) ),
Bivariate( Y( :RstPulse ), X( :MaxPulse ) ),
<<{Arrange in Rows( 2 )},
By( :Sex )
)
)
);
```

Learn it once, use it forever!

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Here is an example script using a methodlogy I have used many times, that I think produces the results you want.

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
// Setup data to look somewhat like your data
dt << delete columns( 1, 2, 3 );
Column( dt, 1 ) << set name( "SID" );
Column( dt, 2 ) << set name( "X" );
Column( dt, 3 ) << set name( "Y1" );
Column( dt, 4 ) << set name( "Y2" );
Column( dt, 5 ) << set name( "Y3" );
Column( dt, 6 ) << set name( "Y4" );
Column( dt, 7 ) << set name( "Y5" );
Column( dt, 8 ) << set name( "Y6" );
dt << delete columns( Index( 9, 129 ) );
// Determine the number of SIDs
Summarize( dt, SIDgrps = by( SID ) );
// Create the output window
nw = New Window( "Report", MainVLB = V List Box() );
// Create a list to hold the data table names
dtList = {};
// Setup what to do when the display window is closed
nw << on close( For( i = 1, i <= N Items( SIDgrps ), i++, Close( dtList[i], nosave ) ) );
// Loop through the SIDs and generate the required reports
For( i = 1, i <= N Items( SIDgrps ), i++,
dt << select where( :SID == Num( SIDgrps[i] ) );
dtSub = dt << subset( selected rows( 1 ), selected columns( 0 ), invisible );
Insert Into( dtList, dtSub );
dtSub << set name( "SID=" || SIDgrps[i] );
ob = Outline Box( "SID=" || SIDgrps[i],
H List Box(
dtSub = Bivariate( Y( :Y1 ), X( :X ) ),
dtSub = Bivariate( Y( :Y2 ), X( :X ) ),
dtSub = Bivariate( Y( :Y3 ), X( :X ) ),
dtSub = Bivariate( Y( :Y4 ), X( :X ) ),
dtSub = Bivariate( Y( :Y5 ), X( :X ) ),
dtSub = Bivariate( Y( :Y6 ), X( :X ) ),
)
);
// Add the current set of reports to the main display
MainVLB << append( ob );
);
```

Jim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

From your description, it seems like all you have to do is use SID in the By role.

```
Bivariate(
Y( :Y1, :Y2, :Y3, :Y4, :Y5, :Y6 ),
X( :X ),
By( :SID )
);
```

Learn it once, use it forever!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Arrange in rows by group

The code from txnelson does the job, Though in his example I needed comment out the code line

//dt << delete columns( Index( 9, 129 ) ); for it to run.

I must admit, I don't fully understand it and I stumbled a bit with this line

dt << **select where****(** :SID == Num**(** SIDgrps**[**i**]** **)** **)**; since my ID is actually character. I removed the Num() to get it to work.

Mark's solution only does the by SID grouping but does not group the plots in rows.

Andy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Arrange in rows by group

This shows one way to control the layout but the resulting array of plots is the transpose of what you want.

```
New Window( "In a Row",
Line Up Box( N Col( 2 ),
Bivariate(
Y( :age, :weight, :oxy, :runtime ),
X( :runpulse ),
By( :sex )
)
)
);
```

Learn it once, use it forever!

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I think this way might be simpler and give you the layout you want:

```
New Window( "Fitness - Bivariate",
V List Box(
Fit Group(
Bivariate( Y( :Age ), X( :MaxPulse ) ),
Bivariate( Y( :Weight ), X( :MaxPulse ) ),
Bivariate( Y( :Oxy ), X( :MaxPulse ) ),
Bivariate( Y( :Runtime ), X( :MaxPulse ) ),
Bivariate( Y( :RunPulse ), X( :MaxPulse ) ),
Bivariate( Y( :RstPulse ), X( :MaxPulse ) ),
<<{Arrange in Rows( 2 )},
By( :Sex )
),
Fit Group(
Bivariate( Y( :Age ), X( :MaxPulse ) ),
Bivariate( Y( :Weight ), X( :MaxPulse ) ),
Bivariate( Y( :Oxy ), X( :MaxPulse ) ),
Bivariate( Y( :Runtime ), X( :MaxPulse ) ),
Bivariate( Y( :RunPulse ), X( :MaxPulse ) ),
Bivariate( Y( :RstPulse ), X( :MaxPulse ) ),
<<{Arrange in Rows( 2 )},
By( :Sex )
)
)
);
```

Learn it once, use it forever!