Hello guys! I have been messing around with R for a while now, but this situation has me a bit stumped. I was unable to solve it by reading documentation. So I have this table (currently in Excel - could export it as csv) with values in 3 columns. Let's call them value P (for position), value B (beginning) and E (end). P represents the position of a mutation in the genome, B and E are the beginnings and ends of a nearby gene that either contains the mutation or not. I am trying to compute the distance between the mutation and the gene. If the mutation is contained in the gene, that is value P is greater than B and lesser than E, the result is 0. If the mutation is "left" of the gene, the distance is negative and is equal to P-B. If the mutation is "right" of the gene, the distance is positive and is equal to P-E. How would i achieve this in R? Regards and thanks, S. [[alternative HTML version deleted]]