i am trying to find the solution to my problem:
how many points per group lay on the straight line
I could not find any solution for this problem in R...
Below You have a sample data and as well plot just to show you how does it look like:
data <- structure(list(Group = c(22782L, 22782L, 22782L, 22782L, 22782L,
22782L, 22782L, 22782L, 22782L, 22782L, 22782L, 22782L, 22782L,
22782L, 22782L, 22782L, 22782L, 22782L, 22782L, 22782L, 22782L,
22782L, 22782L, 22782L, 22782L, 22782L, 22782L, 22782L, 22782L,
22782L, 22782L, 22782L, 22782L, 22782L, 22782L, 22782L, 22782L,
22782L, 22782L, 22782L, 22782L, 22782L, 22782L, 22782L, 22782L,
22782L, 11553L, 11553L, 11553L, 11553L, 11553L, 7059L, 7059L,
7059L, 7059L, 22782L), x = c(100L, 150L, 250L, 287L, 312L, 387L,
475L, 550L, 837L, 937L, 987L, 1087L, 1175L, 1300L, 1325L, 1487L,
1662L, 1700L, 1725L, 1812L, 1912L, 2412L, 3012L, 3562L, 4162L,
4762L, 5362L, 5750L, 5712L, 6225L, 6825L, 6887L, 7237L, 7850L,
7800L, 7937L, 7975L, 8275L, 8362L, 8662L, 8725L, 8950L, 9100L,
9312L, 9400L, 9600L, 4637L, 900L, 4187L, 5800L, 7075L, 1125L,
3400L, 3562L, 3462L, 5412L), y = c(493L, 482L, 479L, 476L, 481L,
479L, 474L, 480L, 480L, 491L, 489L, 490L, 485L, 485L, 485L, 479L,
482L, 482L, 482L, 482L, 484L, 489L, 491L, 489L, 496L, 498L, 500L,
0L, 498L, 500L, 502L, 506L, 497L, 0L, 495L, 506L, 497L, 494L,
498L, 500L, 496L, 499L, 496L, 495L, 495L, 498L, 825L, 284L, 850L,
360L, 790L, 861L, 883L, 882L, 881L, 502L)), row.names = c(23L,
24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L,
37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L,
64L, 65L, 66L, 67L, 68L, 69L, 281L, 312L, 313L, 315L, 316L, 377L,
378L, 380L, 511L, 815L), class = "data.frame")
Data consist of group name column (3 Groups in this case), x and y coordinates:
Group x y
22782 100 493
22782 150 482
22782 250 479
22782 287 476
22782 312 481
Below we can find a plot of the group 22782:
As You can see there are many points that lay almost exactly on the same line and i would like to find out how many of them per group correspond to this condition.
Expected Output would look like this:
Group Max Points
22782 20
I would appreciate any help or tips! Thanks