Removes or flags records with equal latitude and longitude coordinates, either exact or absolute. Equal coordinates can often indicate data entry errors.
Usage
cc_equ(
x,
lon = "decimalLongitude",
lat = "decimalLatitude",
test = "absolute",
value = "clean",
verbose = TRUE
)
Arguments
- x
data.frame. Containing geographical coordinates and species names.
- lon
character string. The column with the longitude coordinates. Default = “decimalLongitude”.
- lat
character string. The column with the latitude coordinates. Default = “decimalLatitude”.
- test
character string. Defines if coordinates are compared exactly (“identical”) or on the absolute scale (i.e. -1 = 1, “absolute”). Default is to “absolute”.
- value
character string. Defining the output value. See value.
- verbose
logical. If TRUE reports the name of the test and the number of records flagged.
Value
Depending on the ‘value’ argument, either a data.frame
containing the records considered correct by the test (“clean”) or a logical vector (“flagged”), with TRUE = test passed and FALSE = test failed/potentially problematic . Default = “clean”.
Examples
x <- data.frame(species = letters[1:10],
decimalLongitude = runif(100, -180, 180),
decimalLatitude = runif(100, -90,90))
cc_equ(x)
#> Testing equal lat/lon
#> Removed 0 records.
#> species decimalLongitude decimalLatitude
#> 1 a -161.625770 -45.8964525
#> 2 b -97.442778 -40.3429792
#> 3 c -27.372120 18.8966226
#> 4 d -24.543565 -66.8138247
#> 5 e -20.903592 -51.0896301
#> 6 f -147.125420 53.1860334
#> 7 g -18.147530 54.4850468
#> 8 h -136.917648 75.2545199
#> 9 i 134.398868 -55.3010813
#> 10 j 130.398895 -2.0749020
#> 11 a -151.974892 -29.0385979
#> 12 b 98.967760 30.8443183
#> 13 c -175.391273 -1.9345365
#> 14 d -170.778842 38.7466443
#> 15 e -48.704950 41.4713434
#> 16 f -49.927961 16.7362663
#> 17 g 17.003857 85.1090253
#> 18 h -15.760050 -63.3272053
#> 19 i -82.740758 3.1337938
#> 20 j -29.728993 88.1689023
#> 21 a -12.092665 72.3660012
#> 22 b -161.494702 -52.9107388
#> 23 c 126.326120 -3.9552188
#> 24 d 90.744828 -29.3028608
#> 25 e -161.564158 13.5739108
#> 26 f -50.152861 38.7825349
#> 27 g -157.599155 85.4215516
#> 28 h -161.656346 -11.0588947
#> 29 i 99.822319 -33.7177080
#> 30 j 120.089514 -79.3217446
#> 31 a -129.759011 -36.4751958
#> 32 b -40.776709 47.9396237
#> 33 c 114.135268 11.6278300
#> 34 d -121.043409 -40.6425046
#> 35 e -2.187415 83.6978360
#> 36 f 21.718341 83.2533258
#> 37 g -114.205167 44.7291734
#> 38 h -115.219970 18.9856369
#> 39 i -35.102832 0.5371615
#> 40 j 97.778952 -43.6354266
#> 41 a 18.338473 57.1221305
#> 42 b -134.905156 -89.0197101
#> 43 c 106.449338 -86.7434265
#> 44 d 43.765229 -8.6421751
#> 45 e -61.445859 22.2307249
#> 46 f -46.800470 8.9177068
#> 47 g 38.034806 -19.5192431
#> 48 h -4.863544 25.4398622
#> 49 i 43.793848 13.6320957
#> 50 j -167.142810 54.5957426
#> 51 a 154.860537 -87.7391164
#> 52 b -22.510054 31.7955792
#> 53 c 40.419765 -71.4466831
#> 54 d 89.535452 4.6166961
#> 55 e -22.641424 -33.8021373
#> 56 f -156.173825 -46.2096136
#> 57 g -40.111114 -71.6633627
#> 58 h 122.276037 -16.0380046
#> 59 i -42.064244 72.2806025
#> 60 j 135.914468 -36.5954923
#> 61 a 45.433170 -36.8099412
#> 62 b -7.683545 31.6145775
#> 63 c -84.369999 -20.9491795
#> 64 d 68.451757 26.5751607
#> 65 e 78.903425 -27.9289475
#> 66 f -81.221408 58.3555793
#> 67 g 169.453078 52.1219060
#> 68 h -49.576264 89.3542093
#> 69 i 162.708561 40.3665862
#> 70 j -114.271810 -38.7158358
#> 71 a -80.880008 39.4764166
#> 72 b 149.323498 -80.9338769
#> 73 c -151.824399 68.5765372
#> 74 d -99.092280 -26.6452615
#> 75 e 8.226703 -52.0040897
#> 76 f 48.403941 -80.8463004
#> 77 g 22.789370 -46.4138179
#> 78 h 54.584245 -34.3516834
#> 79 i 68.731347 68.3356711
#> 80 j 109.499181 55.1552887
#> 81 a -131.029676 -84.0069098
#> 82 b -161.667034 -53.7299836
#> 83 c 15.916315 71.6771995
#> 84 d 117.756823 -51.0008373
#> 85 e -48.475574 56.5513017
#> 86 f -56.415288 -76.7266530
#> 87 g -33.271024 65.1424824
#> 88 h -105.765019 72.9259349
#> 89 i -24.539956 -54.3399691
#> 90 j 4.254729 -60.2709768
#> 91 a -115.889353 6.1078951
#> 92 b -129.067410 -2.5454734
#> 93 c -65.348374 45.1907828
#> 94 d -137.260092 -54.4308461
#> 95 e -103.329325 29.0101492
#> 96 f 165.616773 74.2567614
#> 97 g 48.425219 85.3011427
#> 98 h -68.773123 -53.3600702
#> 99 i -59.111412 -18.0094972
#> 100 j -58.166807 -66.5199545
cc_equ(x, value = "flagged")
#> Testing equal lat/lon
#> Flagged 0 records.
#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [31] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [46] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [61] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [76] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#> [91] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE