cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
jojmp
Level III

How do we filter data based on time and take the average using JSL?

I have data captured for a particular duration of time. Please find below snapshot of the table (attached the same):

TimeStampABC
0.00110.005450.4451428.9093
0.00210.01450.8904429.0295
0.00310.015451.336429.0177
0.00410.02451.7818428.9279
0.00510.025452.2278428.8491

 

The plot of column C looks like below:
time_avg.jpg

I need to filter the rows in section1 , 2 & 3 and find their average.

Each section spans for 30second duration which is calculated from timestamp column  and there is a 20 second interval between each section.
The final result table should be as below:

Sectionmean(A)mean(B)mean(C)
110.005450.4451428.9093
210.01450.8904429.0295
310.015451.336429.0177


Could you please advise how can we filter the rows in section1 , 2 & 3 and find their average using script.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How do we filter data based on time and take the average using JSL?

Here is how I would do it.  It does not match your results, but it does follow the directions you indicated, calculating the Section based upon the TimeStamp values of 0-30 = Section 1, 50-80 = Section 2, 100-130 = Section 3

section.PNG

names default to here(1);
dt=current data table();
dt << new column("Section",
	ordinal,
	formula(
		If( 0 <= :TimeStamp <= 30,
			1,
			50 <= :TimeStamp <= 80,
			2,
			100 <= :TimeStamp <= 130,
			3
		)
	)
);

dt << Summary(
	Group( :Section ),
	Mean( :A ),
	Mean( :B ),
	Mean( :C ),
	Freq( "None" ),
	Weight( "None" ),
	Link to original data table( 0 )
);
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: How do we filter data based on time and take the average using JSL?

Here is how I would do it.  It does not match your results, but it does follow the directions you indicated, calculating the Section based upon the TimeStamp values of 0-30 = Section 1, 50-80 = Section 2, 100-130 = Section 3

section.PNG

names default to here(1);
dt=current data table();
dt << new column("Section",
	ordinal,
	formula(
		If( 0 <= :TimeStamp <= 30,
			1,
			50 <= :TimeStamp <= 80,
			2,
			100 <= :TimeStamp <= 130,
			3
		)
	)
);

dt << Summary(
	Group( :Section ),
	Mean( :A ),
	Mean( :B ),
	Mean( :C ),
	Freq( "None" ),
	Weight( "None" ),
	Link to original data table( 0 )
);
Jim
jojmp
Level III

Re: How do we filter data based on time and take the average using JSL?

Is it possible to give some meaningful names to each section instead of 1, 2 and 3. For example can we name it as interval_1, interval_2 etc.
I tried this but the code doesn't run when I try it 

txnelson
Super User

Re: How do we filter data based on time and take the average using JSL?

In the example I provided, the Section column was created as a Numeric column.  The values for numeric columns have to be valid numbers.  However, it is a simple matter to make the column a Character column and then the values of Section can be anything you want.

names default to here(1);
dt=current data table();
dt << new column("Section",
	ordinal,character,
	formula(
		If( 0 <= :TimeStamp <= 30,
			"Interval_1",
			50 <= :TimeStamp <= 80,
			"Interval_2",
			100 <= :TimeStamp <= 130,
			"Interval_3"
		)
	)
);

I strongly suggest that you take the time to read the Discovering JMP and Using JMP documents from the JMP Documentation Library available under the Help pull down menu

Jim
jojmp
Level III

Re: How do we filter data based on time and take the average using JSL?

Thanks a lot for guiding me to the right resources, I will definitely read the documentation.