- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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];
);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I associate three different columns together using namespace?
This works - thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I associate three different columns together using namespace?
thank you!