Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Yu
Yu
Level II

create an array

i want to create a num array, but how could i do it? example: if i have a data table,i want to use mean value of the first two columns and  maximum of the last six columns to make an array, but i failed. 

a=mean(:column 1);
b=mean(:column 2);
c=max(:column 3);
d=max(:column 4);
e=max(:column 5);
f=max(:column 6);
g=max(:column 7);
h=max(:column 8);

array1=[a,b,c,d,e,f,g,h];

 the jsl file i written is  wrong, how could i correct it. thank you very much.

2 REPLIES 2
Highlighted
ian_jmp
Staff

Re: create an array

Here's one way :

NamesDefaultToHere(1);

// Make some data
dt = NewTable("Test",
		NewColumn("Col 1", Formula(RandomNormal())),
		NewColumn("Col 2", Formula(RandomNormal())),
		NewColumn("Col 3", Formula(RandomNormal())),
		NewColumn("Col 4", Formula(RandomNormal())),
		NewColumn("Col 5", Formula(RandomNormal())),
		NewColumn("Col 6", Formula(RandomNormal())),
		NewColumn("Col 7", Formula(RandomNormal())),
		NewColumn("Col 8", Formula(RandomNormal())),
		<< addRows(10)
		);
		
// Get the statistics into a column vector using data table subscripting
myStats = Matrix({
				Mean(dt[0, 1]),
				Mean(dt[0, 2]),
				Max(dt[0, 3]),
				Max(dt[0, 4]),
				Max(dt[0, 5]),
				Max(dt[0, 6]),
				Max(dt[0, 7]),
				Max(dt[0, 8])
				});
Print(Round(myStats, 3));
Highlighted
Yu
Yu
Level II

Re: create an array

thank you very much! It is an excellent solution!

Article Labels

    There are no labels assigned to this post.