- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
If Statement in For Loop Error
Hi! I am having trouble with putting my if statement in my for loop. I want my if statement to evalaute which elements in the array matches the word "Continuous", and store that column's data in a seperate array/list ( a suggestion for the best way to store coloumn data would also be helpful). I'd appreciate any help! Thanks.
Column Data = {};
for(i= 0, i <= ncol, i++,
if ((Result[i] == "Continuous"),
ColumnData = Column(columnName[i])
);
);
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: If Statement in For Loop Error
Hi, I don't have time to test your script but at first glance I can see a couple of issues:
1) You do not define the table to be used by your script
2) Your call of "ncol" does not refer to any data table
3) You do not define the variable "Result" which you use as an array
4) Reference to a specific column content with "Column (ColumnName [i])" is not likely to work, maybe trying something like just "column[i]" might work better
5) Your assignment to "ColumnData" is not likely to work as you want because you are not appending each column content to the variable "ColumnData"
1) You do not define the table to be used by your script
2) Your call of "ncol" does not refer to any data table
3) You do not define the variable "Result" which you use as an array
4) Reference to a specific column content with "Column (ColumnName [i])" is not likely to work, maybe trying something like just "column[i]" might work better
5) Your assignment to "ColumnData" is not likely to work as you want because you are not appending each column content to the variable "ColumnData"
Thierry R. Sornasse
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: If Statement in For Loop Error
Names Default To Here( 1 );
dt = Open(Example.jmp");
columnName = dt << Get Column Names (String);
ncol = 4;
Result = {"Continuous", "Continuous", "Categorical", "Continuous") // this is variable
ColumnData = {};
for(i= 0, i <= ncol, i++,
if ((Result[i] == "Continuous"), // i am getting an error for this statement
ColumnData = Column(columnName[i])
// i want to store just column data and put it into a matrix, and perform operations on it
);
);
Thank you for your quick response. I apologize for not providng enough details earlier. Are you able to tell what is wrong with the code above? I appreciate your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content