cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
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
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));
Yu
Yu
Level II

Re: create an array

thank you very much! It is an excellent solution!