Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Re: Column value is based dominate element of topic vector

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 4, 2017 11:30 PM
(4033 views)

I've used the text analysis tool and saved off a topic vector to my dataset. This shows up as 10 new columns labeled Topic1 through Topic10. I want a new column called "dominant topic" which is labeled topic 1-10 based based on which of the previous 10 columns had the largest value. What's the easiest way to do this? I suppose I could write a large formula, but I'm hoping someone knows an easier way.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Here is a formula that will do what you want

```
If( Row() == 1,
varList = {"Topic1", "Topic2", "Topic3", "Topic4", "Topic5", "Topic6",
"Topic7", "Topic8", "Topic9", "Topic10"}
);
valueList = {};
For( i = 1, i <= N Items( varList ), i++,
Insert Into( valueList, As Column( varList[i] ) )
);
TheTopic = "Topic" || Char( Contains( valueList, Max( valueList ) ) );
TheTopic;
```

Jim

2 REPLIES 2

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Here is a formula that will do what you want

```
If( Row() == 1,
varList = {"Topic1", "Topic2", "Topic3", "Topic4", "Topic5", "Topic6",
"Topic7", "Topic8", "Topic9", "Topic10"}
);
valueList = {};
For( i = 1, i <= N Items( varList ), i++,
Insert Into( valueList, As Column( varList[i] ) )
);
TheTopic = "Topic" || Char( Contains( valueList, Max( valueList ) ) );
TheTopic;
```

Jim

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Column value is based dominate element of topic vector

Wow! That's very cool code. I didn't even know that functionality existed, but that totally worked. I'm now going to use this as a template for other things as well. Thank you very much. You've not only help me with this problem, but you've opened up a new world of jmp functionality to me.

Article Labels

There are no labels assigned to this post.