-
Notifications
You must be signed in to change notification settings - Fork 0
/
00_libraries.R
70 lines (64 loc) · 1.63 KB
/
00_libraries.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# 00_libraries.R
library(tidyverse)
library(broom)
library(broom.mixed)
library(modelr)
library(lme4)
library(lmerTest)
library(nlme)
library(emmeans)
library(lubridate)
library(tmap)
library(tmaptools)
library(sf)
library(mapview)
library(DBI)
library(RPostgres)
library(parameters)
# detach("package:reSET", unload = TRUE)
library(reSET)
library(SETr) # Kim Cressman's SET package from GitHub.
library(gganimate)
library(tncThemes)
library(leafsync)
# library(plotly)
library(tmap)
library(tmaptools)
library(crosstalk)
library(gt)
library(knitr)
library(kableExtra)
library(patchwork)
#
library(arcgisbinding)
arc.check_product()
library("microclimloggers")
library(rmdformats)
library(here)
library(readxl)
library(units)
library(glue)
library(flexplot)
library(tsibble)
library(tsbox)
library(sugrrants)
library(ggrepel)
library(ggiraph)
library(suncalc)
library(extrafont)
library(hrbrthemes)
# Function to calculate the standard error
stder <- function(x){ sqrt(var(x,na.rm=TRUE)/length(na.omit(x)))}
# refresh reSET package
resetr <- function(){detach("package:reSET", unload = TRUE)
library(reSET)}
# sample entire set of a random group (from group_by variable)
sample_n_groups <- function(tbl, size, replace = FALSE, weight = NULL) {
# regroup when done
grps = tbl %>% groups %>% lapply(as.character) %>% unlist
# check length of groups non-zero
keep = tbl %>% summarise() %>% ungroup() %>% sample_n(size, replace, weight)
# keep only selected groups, regroup because joins change count.
# regrouping may be unnecessary but joins do something funky to grouping variable
tbl %>% right_join(keep, by=grps) %>% group_by_(.dots = grps)
}