cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
patriciafm811
Level II

Find row differences

Hello, 

I am working on a file and I need to determine if any of the numbers in the 'Pos UCN' column are within 10 of any other row in that column. For example, rows 6344 and 6345 are within 10 of each other. How do I identify that? I know that this will create a new column, which is what I want. I have spent 2 days on the user community trying various things and have not had any luck. 

patriciafm811_0-1731935443448.png

 

 

the difference between the rows. I believe this would creat a new column of 'difference' between the. I would also like to identify (in another new column)

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Find row differences

One option is to change the Diff column to perform the comparison

If(Dif(Num(:Pos UCN), 1) <= 5 | Abs(Dif(Num(:Pos UCN), -1)) <= 5,
	1,
	0
)

Or just calculate minimum difference and then perform check after

Min(Dif(Num(:Pos UCN), 1), Abs(Dif(Num(:Pos UCN), -1)))
-Jarmo

View solution in original post

9 REPLIES 9
mmarchandFSLR
Level IV

Re: Find row differences

What do you want to do with the values that contain characters?

patriciafm811
Level II

Re: Find row differences

They have to be character values because I need the leading 0's. 

mmarchandFSLR
Level IV

Re: Find row differences

I was talking about these:

 

mmarchandFSLR_0-1731946586521.png

 

Re: Find row differences

Hello,

 

To get the difference between 2 rows, then you have the formula below.

 

SophieCuvillier_0-1731940403834.png

 

If you want to make sure that your line is at least 10 away from all the other lines, you can do this as follows:

- Convert your column into a number (see what we do with characters)
- Arrange your column in ascending order
- Create the Diff column using the formula above and check if there are some diff < 10

 

patriciafm811
Level II

Re: Find row differences

Thank you. This gives me a count difference between rows. Now how do I highlight rows that a difference of less than 10?

Re: Find row differences

In the same way, you can create a formula as below to get if the difference is less than 10 (1) or not (0) in a new column

 

SophieCuvillier_0-1731941430105.png

 

And use color values property to highlight rows with less than 10 of difference

 

SophieCuvillier_1-1731941463867.png

 

SophieCuvillier_2-1731941473623.png

 

txnelson
Super User

Re: Find row differences

You can also set the rowstate to selected for the rows you find that have met the criteria

dt << select rows(.....)
Jim
patriciafm811
Level II

Re: Find row differences

So I was able to make my two additional columns (Diff and Prev UCN <=5). But I want to be able to get both the numbers. So for row 6345, it identifies as a previous row within 5, but I want to also identify that row before (6344)? This is looking for a "Pos UCN" +/- 5 to see if there are numbers that are close together. If they are close together, I want to identify both so I can look further and determine any potential issues. 

jthi
Super User

Re: Find row differences

One option is to change the Diff column to perform the comparison

If(Dif(Num(:Pos UCN), 1) <= 5 | Abs(Dif(Num(:Pos UCN), -1)) <= 5,
	1,
	0
)

Or just calculate minimum difference and then perform check after

Min(Dif(Num(:Pos UCN), 1), Abs(Dif(Num(:Pos UCN), -1)))
-Jarmo