Choose Language Hide Translation Bar
Highlighted
Level I

## Column value is based dominate element of topic vector

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
Super User

## Re: Column value is based dominate element of topic vector

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
Super User

## Re: Column value is based dominate element of topic vector

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
Level I

## 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.