- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How to subset data with some headers in rows?
Hi, I have a big data which has headers inside some rows. I wanted to subset the data per header with its value. My data looks something like this:
Header 1 | Column 2 | Column 3 | Column 4 |
1 | 1 | 1 | 1 |
1 | 1 | 1 | 1 |
1 | 1 | 1 | 1 |
Header 2 | Column 2 | Column 3 | Column 4 |
2 | 2 | 2 | 2 |
2 | 2 | 2 | 2 |
Header 3 | Column 2 | Column 3 | Column 4 |
3 | 3 | 3 | 3 |
3 | 3 | 3 | 3 |
3 | 3 | 3 | 3 |
I need to subset the data per Header, so I should have Header 2 with
Header 2 | Column 2 | Column 3 | Column 4 |
2 | 2 | 2 | 2 |
2 | 2 | 2 | 2 |
Header 3
Header 3 | Column 2 | Column 3 | Column 4 |
3 | 3 | 3 | 3 |
3 | 3 | 3 | 3 |
3 | 3 | 3 | 3 |
I tried creating a Flag column, assign 1 to each header then subset. But the result is incorrect as it subset 1 and blank with Subset 1 with all the headers. This is what I created:
CSV << New Column ("Flag", Numeric);
r = CSV << getRowsWhere( Contains( :Header 1, "Header " ));
Column(CSV, "Flag")[r] = 1;
Please help
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to subset data with some headers in rows?
Move Header1 "down" from the column name (if it is there),
create flag column with formula such as
If(Starts With(:Column 1, "Header"),
flag = :Column 1
);
flag;
Then you can subset using that new column as By
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to subset data with some headers in rows?
Move Header1 "down" from the column name (if it is there),
create flag column with formula such as
If(Starts With(:Column 1, "Header"),
flag = :Column 1
);
flag;
Then you can subset using that new column as By
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to subset data with some headers in rows?
Sorry, Im a little bit confused. How did you create Header1 Column?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to subset data with some headers in rows?
Using Column Names -> Move down
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to subset data with some headers in rows?
If(Starts With(:Column 1, "Header"),
flag = :Column 1
);
flag;
cool , temporary flag - available also for subsequent rows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to subset data with some headers in rows?
You might want to make it a bit more robust by making sure it has been initialized for example by using As Constant() (or If(Row() == 1,....). In this case is wasn't necessary so I didn't bother with it
As Constant(flag = "");
If(Starts With(:Column 1, "Header"),
flag = :Column 1
);
flag;
Also the readability might improve with something like
As Constant(flag = "");
If(Starts With(:Header 1, "Header"),
flag = :Header 1
,
flag
)
You just want to "return" the value you wish to see in rows.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to subset data with some headers in rows?
I mean Column 5, sorry for the confusion. Is that from the formula? Im using JMP16 and it has an error
Name Unresolved: flag in access or evaluation of 'flag' , flag/*###*/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to subset data with some headers in rows?
After having correct column headers, create new column with a formula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to subset data with some headers in rows?
Can this be done using JSL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to subset data with some headers in rows?
Yes. I think JMP can record all these actions and you can get the script from enhanced log (or build workflow)