Running examples in ‘scrubr-Ex.R’ failed
The error most likely occurred in:

> ### Name: coords
> ### Title: Coordinate based cleaning
> ### Aliases: coords coord_incomplete coord_imprecise coord_impossible
> ###   coord_unlikely coord_within coord_pol_centroids coord_uncertain
> 
> ### ** Examples
> 
> df <- sample_data_1
> 
> # Remove impossible coordinates
> NROW(df)
[1] 1500
> df[1, "latitude"] <- 170
> df <- dframe(df) %>% coord_impossible()
Assuming 'latitude' is latitude
Assuming 'longitude' is longitude
> NROW(df)
[1] 1499
> attr(df, "coord_impossible")
# A tibble: 1 x 5
  name             longitude latitude date                       key
  <chr>                <dbl>    <dbl> <dttm>                   <int>
1 Ursus americanus     -79.7      170 2015-01-14 16:36:45 1065590124
> 
> # Remove incomplete cases
> NROW(df)
[1] 1499
> df_inc <- dframe(df) %>% coord_incomplete()
> NROW(df_inc)
[1] 1305
> attr(df_inc, "coord_incomplete")
# A tibble: 194 x 5
   name  longitude latitude date                  key
   <chr>     <dbl>    <dbl> <dttm>              <int>
 1 <NA>         NA       NA NA                     NA
 2 <NA>         NA       NA NA                     NA
 3 <NA>         NA       NA NA                     NA
 4 <NA>         NA       NA NA                     NA
 5 <NA>         NA       NA NA                     NA
 6 <NA>         NA       NA NA                     NA
 7 <NA>         NA       NA NA                     NA
 8 <NA>         NA       NA NA                     NA
 9 <NA>         NA       NA NA                     NA
10 <NA>         NA       NA NA                     NA
# … with 184 more rows
> 
> 
> # Remove imprecise cases
> df <- sample_data_5
> NROW(df)
[1] 39
> ## remove records that don't have decimals at all
> df_imp <- dframe(df) %>% coord_imprecise(which = "has_dec")
Assuming 'latitude' is latitude
Assuming 'longitude' is longitude
> NROW(df_imp)
[1] 33
> attr(df_imp, "coord_imprecise")
# A tibble: 6 x 5
  name             longitude  latitude date                        key
  <chr>            <chr>      <chr>    <chr>                     <int>
1 Ursus americanus -123.829   40       2015-03-28T23:00:00Z 1132403409
2 Ursus americanus -103.32315 29       2015-05-23T20:11:29Z 1092907160
3 Ursus americanus -110       44.59889 2015-05-02T22:00:00Z 1092897387
4 Ursus americanus -109       31       2015-05-29T15:02:01Z 1098900981
5 Ursus americanus -92.29988  49       2015-05-16T16:27:20Z 1132401463
6 Ursus americanus -110.0     44       2015-05-10T18:05:40Z 1088979156
> ## remove records that have all zeros
> df_imp <- dframe(df) %>% coord_imprecise(which = "no_zeros")
Assuming 'latitude' is latitude
Assuming 'longitude' is longitude
> NROW(df_imp)
[1] 28
> attr(df_imp, "coord_imprecise")
# A tibble: 11 x 5
   name             longitude latitude date                        key
   <chr>            <chr>     <chr>    <chr>                     <int>
 1 Ursus americanus -78.25027 36.0000  2015-03-20T21:11:24Z 1088923534
 2 Ursus americanus -72.18191 44.0000  2015-04-16T16:16:30Z 1088950245
 3 Ursus americanus -100.0000 25.6065  2015-04-06T22:00:00Z 1099969743
 4 Ursus americanus -115.0000 51.22819 2015-05-14T01:15:34Z 1092879993
 5 Ursus americanus -110.0000 31.87244 2015-05-08T16:49:41Z 1099958687
 6 Ursus americanus -72.0000  43.80838 2015-05-27T11:09:14Z 1092905944
 7 Ursus americanus -102.00   28.57147 2015-05-05T22:00:00Z 1088972152
 8 Ursus americanus -103.0    29.26837 2015-05-23T20:43:13Z 1092907155
 9 Ursus americanus -81.0     46.03828 2015-05-29T21:23:21Z 1099959710
10 Ursus americanus -81.30308 46.0     2015-05-21T21:21:25Z 1092890386
11 Ursus americanus -110.0    44       2015-05-10T18:05:40Z 1088979156
> ## remove both records that don't have decimals at all and those that
> ## have all zeros
> df_imp <- dframe(df) %>% coord_imprecise(which = "both")
Assuming 'latitude' is latitude
Assuming 'longitude' is longitude
> NROW(df_imp)
[1] 23
> attr(df_imp, "coord_imprecise")
# A tibble: 16 x 5
   name             longitude  latitude date                        key
   <chr>            <chr>      <chr>    <chr>                     <int>
 1 Ursus americanus -123.829   40       2015-03-28T23:00:00Z 1132403409
 2 Ursus americanus -103.32315 29       2015-05-23T20:11:29Z 1092907160
 3 Ursus americanus -110       44.59889 2015-05-02T22:00:00Z 1092897387
 4 Ursus americanus -109       31       2015-05-29T15:02:01Z 1098900981
 5 Ursus americanus -92.29988  49       2015-05-16T16:27:20Z 1132401463
 6 Ursus americanus -110.0     44       2015-05-10T18:05:40Z 1088979156
 7 Ursus americanus -78.25027  36.0000  2015-03-20T21:11:24Z 1088923534
 8 Ursus americanus -72.18191  44.0000  2015-04-16T16:16:30Z 1088950245
 9 Ursus americanus -100.0000  25.6065  2015-04-06T22:00:00Z 1099969743
10 Ursus americanus -115.0000  51.22819 2015-05-14T01:15:34Z 1092879993
11 Ursus americanus -110.0000  31.87244 2015-05-08T16:49:41Z 1099958687
12 Ursus americanus -72.0000   43.80838 2015-05-27T11:09:14Z 1092905944
13 Ursus americanus -102.00    28.57147 2015-05-05T22:00:00Z 1088972152
14 Ursus americanus -103.0     29.26837 2015-05-23T20:43:13Z 1092907155
15 Ursus americanus -81.0      46.03828 2015-05-29T21:23:21Z 1099959710
16 Ursus americanus -81.30308  46.0     2015-05-21T21:21:25Z 1092890386
> 
> 
> # Remove unlikely points
> NROW(df)
[1] 39
> df_unlikely <- dframe(df) %>% coord_unlikely()
Assuming 'latitude' is latitude
Assuming 'longitude' is longitude
> NROW(df_unlikely)
[1] 39
> attr(df_unlikely, "coord_unlikely")
[1] NA
> 
> # Remove points not within correct political borders
> if (requireNamespace("rgbif", quietly = TRUE) && interactive()) {
+    library("rgbif")
+    wkt <- 'POLYGON((30.1 10.1,40 40,20 40,10 20,30.1 10.1))'
+    res <- rgbif::occ_data(geometry = wkt, limit=300)$data
+ } else {
+    res <- sample_data_4
+ }
> 
> ## By specific country name
> NROW(res)
[1] 100
> df_within <- dframe(res) %>% coord_within(country = "Israel")
Error: Please install sf
Execution halted