afribat comes bundled with one csv and one gpkg file in its `inst/extdata` directory. This function make them easy to access.

path_to_file(path = NULL)

Source

This function is adapted from `readxl::readxl_example()`.

Arguments

path

Name of file in quotes with extension; `"afribats.csv"` and `"afribats_sf.gpkg"` will work. If `NULL`, the example files will be listed.

Details

The data in each file is the almost the same. In gpkg file, all missing positions coordinates were removed.

Examples

# load libraries
library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(readr)

path_to_file("afribats.csv")
<<<<<<< HEAD
#> [1] "/private/var/folders/1v/rxqdlk0j0dd4_3wp4tjcbxjm0000gn/T/RtmpmX6Sb8/temp_libpath7e2043823e90/afribat/extdata/afribats.csv"
=======
#> [1] "/private/var/folders/1v/rxqdlk0j0dd4_3wp4tjcbxjm0000gn/T/RtmpqTP0qg/temp_libpath7b2714c68e0e/afribat/extdata/afribats.csv"
>>>>>>> 9cbb00b28be2aaeb16eb622d0b3c405ac022efec
head(read_csv(path_to_file("afribats.csv")))
#> Rows: 17285 Columns: 13
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr  (9): family, genus, species, museum, country, location, reference, holo...
#> dbl  (3): year, latitude, longitude
#> date (1): date
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 6 × 13
#>   family     genus   species  museum  date        year country location latitude
#>   <chr>      <chr>   <chr>    <chr>   <date>     <dbl> <chr>   <chr>       <dbl>
#> 1 Cistugidae Cistugo lesueuri TM2286  1917-09-15  1917 South … Fransch…    -33.7
#> 2 Cistugidae Cistugo lesueuri KM2025  1933-06-01  1933 South … Bedford…    -32.9
#> 3 Cistugidae Cistugo lesueuri KM2031  1933-10-01  1933 South … Bedford…    -32.9
#> 4 Cistugidae Cistugo lesueuri TM29310 1978-07-12  1978 South … Saasvel…    -34.0
#> 5 Cistugidae Cistugo lesueuri TM29511 1979-01-22  1979 South … Karoo NP    -32.3
#> 6 Cistugidae Cistugo lesueuri KM24805 1979-02-03  1979 Lesotho Sehlaba…    -29.9
#> # ℹ 4 more variables: longitude <dbl>, reference <chr>, holotype <chr>,
#> #   checked <chr>
head(read_sf(path_to_file("afribats_sf.gpkg")))
#> Simple feature collection with 6 features and 11 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 18.97 ymin: -33.97 xmax: 29.08 ymax: -29.87
#> Geodetic CRS:  WGS 84
#> # A tibble: 6 × 12
#>   family     genus   species  museum date        year country location reference
#>   <chr>      <chr>   <chr>    <chr>  <date>     <dbl> <chr>   <chr>    <chr>    
#> 1 Cistugidae Cistugo lesueuri TM2286 1917-09-15  1917 South … Fransch… Van Cake…
#> 2 Cistugidae Cistugo lesueuri KM2025 1933-06-01  1933 South … Bedford… Monadjem…
#> 3 Cistugidae Cistugo lesueuri KM2031 1933-10-01  1933 South … Bedford… Monadjem…
#> 4 Cistugidae Cistugo lesueuri TM293… 1978-07-12  1978 South … Saasvel… Monadjem…
#> 5 Cistugidae Cistugo lesueuri TM295… 1979-01-22  1979 South … Karoo NP Monadjem…
#> 6 Cistugidae Cistugo lesueuri KM248… 1979-02-03  1979 Lesotho Sehlaba… Monadjem…
#> # ℹ 3 more variables: holotype <chr>, checked <chr>, geom <POINT [°]>