# install.packages("pacman")
# writeLines(pacman::p_lib(), "~/Desktop/list_of_R_packages.csv") # to quickly back up packages
# remotes::install_github("ThinkR-open/remedy")
pacman::p_load(rio, tidyverse,janitor, data.table, here, sf, readxl, lubridate, leaflet, zoo, gghighlight, ggstatsplot, broom, effects, MuMIn, sjPlot) # just add needed packages to this line and Pacman will install and load them.
Only burrows recorded in 2018 and 2021 had the same effort/area
In 2019 we checked only part of it.
One option is to compare just 2018 and 2021 for all the area. Second is to compare 2018 2019 2021 for small part.
raw <- import(here("data", "burrows.xlsx"))
burrows <- raw %>%
janitor::clean_names()
summary(burrows)
## id person area
## Length:695 Length:695 Length:695
## Class :character Class :character Class :character
## Mode :character Mode :character Mode :character
##
##
##
## date year month day
## Min. :2018-02-14 00:00:00 Min. :2018 Min. :2.000 Min. : 2.00
## 1st Qu.:2018-05-31 00:00:00 1st Qu.:2018 1st Qu.:5.000 1st Qu.:14.00
## Median :2018-06-15 00:00:00 Median :2018 Median :5.000 Median :21.00
## Mean :2018-10-30 22:14:19 Mean :2018 Mean :5.468 Mean :20.23
## 3rd Qu.:2019-05-21 00:00:00 3rd Qu.:2019 3rd Qu.:6.000 3rd Qu.:28.00
## Max. :2021-07-22 00:00:00 Max. :2021 Max. :7.000 Max. :31.00
## age type position scat
## Length:695 Length:695 Length:695 Mode:logical
## Class :character Class :character Class :character NA's:695
## Mode :character Mode :character Mode :character
##
##
##
## gps coord_x coord_y altitude
## Length:695 Min. :16.78 Min. :48.90 Min. :100.0
## Class :character 1st Qu.:16.80 1st Qu.:48.91 1st Qu.:194.7
## Mode :character Median :16.80 Median :48.91 Median :201.0
## Mean :16.80 Mean :48.91 Mean :206.9
## 3rd Qu.:16.80 3rd Qu.:48.91 3rd Qu.:215.6
## Max. :16.83 Max. :48.92 Max. :284.0
## comments
## Length:695
## Class :character
## Mode :character
##
##
##
skimr::skim(burrows)
| Name | burrows |
| Number of rows | 695 |
| Number of columns | 16 |
| _______________________ | |
| Column type frequency: | |
| character | 8 |
| logical | 1 |
| numeric | 6 |
| POSIXct | 1 |
| ________________________ | |
| Group variables | None |
Variable type: character
| skim_variable | n_missing | complete_rate | min | max | empty | n_unique | whitespace |
|---|---|---|---|---|---|---|---|
| id | 0 | 1.00 | 8 | 8 | 0 | 695 | 0 |
| person | 0 | 1.00 | 2 | 2 | 0 | 5 | 0 |
| area | 0 | 1.00 | 15 | 15 | 0 | 1 | 0 |
| age | 217 | 0.69 | 4 | 5 | 0 | 4 | 0 |
| type | 22 | 0.97 | 1 | 5 | 0 | 10 | 0 |
| position | 673 | 0.03 | 7 | 10 | 0 | 2 | 0 |
| gps | 4 | 0.99 | 1 | 5 | 0 | 632 | 0 |
| comments | 692 | 0.00 | 14 | 22 | 0 | 3 | 0 |
Variable type: logical
| skim_variable | n_missing | complete_rate | mean | count |
|---|---|---|---|---|
| scat | 695 | 0 | NaN | : |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| year | 0 | 1 | 2018.41 | 0.73 | 2018.00 | 2018.00 | 2018.00 | 2019.00 | 2021.00 | ▇▃▁▁▁ |
| month | 0 | 1 | 5.47 | 0.53 | 2.00 | 5.00 | 5.00 | 6.00 | 7.00 | ▁▁▇▇▁ |
| day | 0 | 1 | 20.23 | 8.96 | 2.00 | 14.00 | 21.00 | 28.00 | 31.00 | ▃▂▂▅▇ |
| coord_x | 0 | 1 | 16.80 | 0.01 | 16.78 | 16.80 | 16.80 | 16.80 | 16.83 | ▁▇▅▁▁ |
| coord_y | 0 | 1 | 48.91 | 0.00 | 48.90 | 48.91 | 48.91 | 48.91 | 48.92 | ▁▇▂▁▃ |
| altitude | 0 | 1 | 206.86 | 28.69 | 100.00 | 194.70 | 201.00 | 215.55 | 284.00 | ▁▁▇▂▂ |
Variable type: POSIXct
| skim_variable | n_missing | complete_rate | min | max | median | n_unique |
|---|---|---|---|---|---|---|
| date | 0 | 1 | 2018-02-14 | 2021-07-22 | 2018-06-15 | 26 |
# Spatial
burrows_sf <- st_as_sf(burrows, coords = c("coord_x", "coord_y"), crs=4326)
# If you want to set your own colors manually:
pal <- colorFactor(
palette = c('red', 'blue'),
domain = burrows_sf$year
)
# If you want to use predefined palettes in the RColorBrewer package:
# Call RColorBrewer::display.brewer.all() to see all possible palettes
# pal <- colorFactor(
# palette = 'Dark2',
# domain = burrows_sf$year
# )
burrows_sf %>%
dplyr::filter(year %in% c(2018, 2021)) %>%
leaflet() %>%
addTiles() %>%
addCircles(weight = 2,
radius = 3,
color = ~ pal(year))