Reference Data Tables in a Loop to Create DistributionsRe: Reference Data Tables in a Loop to Create Distributions<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />That also worked perfectly! (and it is much easier for me to understand what is going on!) Thank you!!
Re: Reference Data Tables in a Loop to Create DistributionsIf dtPinGroups is a list of variables I think Eval() is needed:
Eval(dtPinGroups[i]) << Distribution( Column(:Leakage_Data));
If you have a list of current table names (as strings) this should also work:
Data Table(dtPinGroupNames[i]) << Distribution( Column(:Leakage_Data));
To build commands as a string – like in PMroz' example – is great to have in your tool box, especially when more straightforward methods refuse to work. But I usually try a direct method first, simply because I find it easier to code (and to read). The former of the approaches above applied to PMroz' example would be:
dt1 = Open("$sample_data/Big Class.jmp");
dt2 = Open("$sample_data/Animals.jmp");
dt3 = Open("$sample_data/Analgesics.jmp");
dtpingroups = {dt1, dt2, dt3};
dtpingroupnames = {"Big Class", "Animals", "Analgesics"};
var_list = {:height, :miles, :pain};
wind = {};
For(i = 1, i <= N Items(dtpingroups), i++,
wind[i] = New Window("Leakage_" || dtpingroupnames[i] || "_Distribution",
Eval(dtpingroups[i]) << Distribution(Continuous Distribution(Column(var_list[i])))
)
);
Re: Reference Data Tables in a Loop to Create DistributionsThank you! That worked perfectly!
Re: Reference Data Tables in a Loop to Create DistributionsTry an approach like this:
dt1 = open("$sample_data/Big Class.jmp");
dt2 = open("$sample_data/Animals.jmp");
dt3 = open("$sample_data/Analgesics.jmp");
dtpingroups = {dt1, dt2, dt3};
dtpingroupnames = {"Big Class", "Animals", "Analgesics"};
var_list = {:height, :miles, :pain};
wind = {};
for (i = 1, i <= nitems(dtpingroups), i++,
one_expr = evalinsert(
"\[ wind = new window("Leakage ^dtpingroupnames^_Distribution",
^dtpingroups^ << Distribution( Continuous Distribution( Column(^var_list^ ) ) )
);]\");
eval(parse(one_expr));
);
I had to build the commands dynamically as a string and then execute them with eval(parse()).