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
- :
- Discussions
- :
- Re: Creating Time Variable

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
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

A week ago
(156 views)

Okay. So when looking at the selected area only. I would want:

Nback#=1, duration=14303912, Cumulative Duration=0

Nback#=2, duration=14305914, Cumulative Duration=2002

Nback#=3, duration=14307916, Cumulative Duration=4004

Nback#=4, duration=14309965, Cumulative Duration=6053

Nback#=5, duration=14312015, Cumulative Duration=8103

Nback#=6, duration=14314051, Cumulative Duration=10139

I need to make this final column as a measure of time. Any guidance would be greatly appreciated.

4 REPLIES

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

A week ago
(125 views)

This script might be what you need. Data set as the attchment.

```
dt = Current Data Table();
//dt << New Column( "Delta", numeric );
dt << New Column( "Cumulative", numeric );
dt << Sort( By( :Category, :Time ), Order( Ascending, Ascending ), Replace table );
For( i = 1, i <= N Rows( dt ), i++,
If( :Time[i] == Min( :Time[dt << get rows where( :Category == :Category[i] )] ),
//dt:Delta[i] = 0;
dt:Cumulative[i] = 0;
,
//dt:Delta[i] = dt:Time[i] - dt:Time[i - 1];
dt:Cumulative[i] = dt:Cumulative[i-1]+ (dt:Time[i] - dt:Time[i - 1]);
)
);
```

Highlighted

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

A week ago
(107 views)

Here is a way to do this with just column formulas. I'm not sure which column you are using to indicate the time reset, so I included

- A method to do this from either a column whose values changes for each new group, and
- A method based on a column that indicates a reset in time.

```
Names default to here ( 1 );
//Table with data similar to yours
dt = New Table( "Data",
Add Rows( 40 ),
New Column( "Space", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( Round( Random Uniform( 1, 5 ), 0 ) )
),
New Column( "Duration", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( Round( Random Uniform( 1998, 2002 ), 0 ) )
),
New Column( "Start", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( If( Row() == 1, :Space, :Space + Lag( :Start, 1 ) + Lag( :Duration, 1 ) ) )
),
New Column( "End", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( :Start + :Duration )
),
New Column( "Period Indication", Character, "Nominal",
Formula( If( Row() < 15, "One", "Two" ) )
),
New Column( "Indication of Time Reset Pulse", Numeric, "Nominal",
Formula( If( Row() == 10, 1, . ) )
)
);
//New Column - subtract the current end time from the first end time in
//the group. Use this if the column :summary_image_end" tells you when
//to start a new group
dt << New Column( "Time In Group", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( :End - Col Min( :Start, :Period Indication ) )
);
//Make a New Column indicating the period for a pulse signal, use this if
//the column Lag1 tells you when to start a new group
dt << New Column( "Period Indication from Pulse", Numeric, "Nominal",
Format( "Best", 12 ),
Formula(
If(
Row() == 1,
1,
Lag( :Period Indication from Pulse, 1 ) +
If(
Is Missing( :Indication of Time Reset Pulse ),
0,
1
)
)
)
);
//Once the group column is made then calculate the duration
dt << New Column( "Time In Group - Pulse", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( :End - Col Min( :Start, :Period Indication from Pulse ) )
);
```

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

Monday
(40 views)

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

Yesterday
(13 views)