cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Andyon98
Level II

How do I associate three different columns together using namespace?

I have three columns of data that I want to associate each row with each other. I was looking at namespace since I have to return a list back to another file. (Assuming I can use one singular list of lists within it to select the rows of data). If this is not the best way to do it (as a result of being too messy or better ways to do it). How can this be achieved?

 

Below is what I have so far, the code only associates two columns together. I'm not sure on how to associate the third. Ideally I would like to associate group2 with group3.

 

NS = New Namespace();

group1 = column("group1")<<GetAsMatrix();
group2 = column("group2")<<GetAsMatrix();
group3 = column("group3")<<GetAsMatrix();
		
NS:group2 = groups;
for(i=1, i<=N Items(group1), i++,
NS:(group2[i]) = group1[i];
);
1 ACCEPTED SOLUTION

Accepted Solutions
ih
Super User (Alumni) ih
Super User (Alumni)

Re: How do I associate three different columns together using namespace?

I don't think you need to use a namespace to accomplish this, maybe just building a list of lists will do what you want. Is this moving the right direction?

 

Names default to here(1);

dt = Open("$Sample_data/iris.jmp");

NS = New Namespace();
col = {};
col[1] = column(dt, "Sepal Length");
col[2] = column(dt, "Sepal Width");
col[3] = column(dt, "Petal Width");

// if you have JMP 16:
coldata1 = transform each ({c}, col, c << GetasMatrix());

// JMP 15 and older:
coldata2 = {};
for(i=1, i<=n items(col), i++,
	coldata2[i] = col[i] << GetasMatrix()
);

// Either way you get the same result:
Show(coldata1 == coldata2);

// All data is in one object you can return to another script:
Show(coldata1);

View solution in original post

5 REPLIES 5
ih
Super User (Alumni) ih
Super User (Alumni)

Re: How do I associate three different columns together using namespace?

I don't think you need to use a namespace to accomplish this, maybe just building a list of lists will do what you want. Is this moving the right direction?

 

Names default to here(1);

dt = Open("$Sample_data/iris.jmp");

NS = New Namespace();
col = {};
col[1] = column(dt, "Sepal Length");
col[2] = column(dt, "Sepal Width");
col[3] = column(dt, "Petal Width");

// if you have JMP 16:
coldata1 = transform each ({c}, col, c << GetasMatrix());

// JMP 15 and older:
coldata2 = {};
for(i=1, i<=n items(col), i++,
	coldata2[i] = col[i] << GetasMatrix()
);

// Either way you get the same result:
Show(coldata1 == coldata2);

// All data is in one object you can return to another script:
Show(coldata1);
Andyon98
Level II

Re: How do I associate three different columns together using namespace?

This works - thank you!

Andyon98
Level II

Re: How do I associate three different columns together using namespace?

If this is in a function, how can I return the list? Im not familiar with the syntax on JSL.

ih
Super User (Alumni) ih
Super User (Alumni)

Re: How do I associate three different columns together using namespace?

Just make that variable the last line in the function, something like this:

 

Names default to here(1);

myfunction = function( {},
	dt = Open("$Sample_data/iris.jmp");

	NS = New Namespace();
	col = {};
	col[1] = column(dt, "Sepal Length");
	col[2] = column(dt, "Sepal Width");
	col[3] = column(dt, "Petal Width");

	// if you have JMP 16:
	coldata1 = transform each ({c}, col, c << GetasMatrix());

	// JMP 15 and older:
	coldata2 = {};
	for(i=1, i<=n items(col), i++,
		coldata2[i] = col[i] << GetasMatrix()
	);

	// Either way you get the same result:
	Show(coldata1 == coldata2);

	// Return the list of lists:
	coldata1
);

show(myfunction());
Andyon98
Level II

Re: How do I associate three different columns together using namespace?

thank you!

Recommended Articles