-
Notifications
You must be signed in to change notification settings - Fork 12
/
get_eubar.R
46 lines (40 loc) · 971 Bytes
/
get_eubar.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
#' @rdname db_getter_backend
#' @export
get_eubar <- function(db_url = get_db_url("eubar")) {
check_if_packages_are_available("readxl")
check_connection_to_url(db_url)
# download data
temp <- tempfile(fileext = ".xlsx")
utils::download.file(db_url, temp, mode = "wb", quiet = TRUE)
# read data
db_raw <- temp %>%
readxl::read_excel(
sheet = 1,
col_types = "text",
na = c("-"),
trim_ws = TRUE
)
# delete temporary file
unlink(temp)
# final data preparation
eubar <- db_raw %>%
dplyr::transmute(
labnr = .[[13]],
c14age = .[[14]],
c14std = .[[15]],
material = .[[18]],
country = .[[10]],
region = .[[9]],
site = .[[1]],
lat = .[[12]],
lon = .[[11]],
feature = .[[19]],
shortref = .[[22]]
) %>%
dplyr::mutate(
sourcedb = "eubar",
sourcedb_version = get_db_version("eubar")
) %>%
as.c14_date_list()
return(eubar)
}