Choose Language Hide Translation Bar
Highlighted
lala
Occasional Contributor

How do get the position by fuzzy matching?

dt=Open("$SAMPLE_DATA\Big Class.jmp");
dt<<Sort(By(4),Order(Ascending),replace table);

In ascending order of height, how do I get the row number of a value that does not appear in the height column that is closest to the height less than this value in the height column?


For example, this value is 54.

 

2020-01-08_19-12.png

Thanks!

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Craige_Hales
Staff (Retired)

Re: How do get the position by fuzzy matching?

This might work, but LocSorted has some edge cases, especially at the lower end, that might make it hard to use. Read the doc and decide what you need to do for the too-small and too-big case. I think it might always return the first row of the set of values, but that isn't documented.  @XanGregg 

dt=Open("$SAMPLE_DATA\Big Class.jmp");
dt<<Sort(By(4),Order(Ascending),replace table);
vector = dt:height<<getasmatrix;
position = loc sorted(vector,[54])[1];
show(dt[position,0]);

dt[position,0] = {"LILLIE", 12, "F", 52, 64};

Craige

View solution in original post

2 REPLIES 2
Highlighted
Craige_Hales
Staff (Retired)

Re: How do get the position by fuzzy matching?

This might work, but LocSorted has some edge cases, especially at the lower end, that might make it hard to use. Read the doc and decide what you need to do for the too-small and too-big case. I think it might always return the first row of the set of values, but that isn't documented.  @XanGregg 

dt=Open("$SAMPLE_DATA\Big Class.jmp");
dt<<Sort(By(4),Order(Ascending),replace table);
vector = dt:height<<getasmatrix;
position = loc sorted(vector,[54])[1];
show(dt[position,0]);

dt[position,0] = {"LILLIE", 12, "F", 52, 64};

Craige

View solution in original post

Highlighted
XanGregg
Staff

Re: How do get the position by fuzzy matching?

Craige is correct: if there is more than one matching value, the index of the first matching value is returned.
0 Kudos