-
Notifications
You must be signed in to change notification settings - Fork 12
/
get_bda.R
66 lines (59 loc) · 1.97 KB
/
get_bda.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
#' @rdname db_getter_backend
#' @export
get_bda <- function(db_url = get_db_url("bda")) {
check_connection_to_url(db_url)
temp <- tempfile(fileext = ".zip")
td <- tempdir()
utils::download.file(
db_url,
temp,
mode="wb",
quiet = TRUE
)
utils::unzip(temp, files="BDA-Table_Dates.xlsx", exdir=td, overwrite=TRUE)
c14dates <- readxl::read_excel(
paste0(td,"/BDA-Table_Dates.xlsx"),
col_types = "text"
)
utils::unzip(temp, files="BDA-Table_Occupations.xlsx", exdir=td, overwrite=TRUE)
c14occupa <- readxl::read_excel(
paste0(td,"/BDA-Table_Occupations.xlsx"),
col_types = "text"
)
utils::unzip(temp, files="BDA-Table_Sites.xlsx", exdir=td, overwrite=TRUE)
c14sites <- readxl::read_excel(
paste0(td,"/BDA-Table_Sites.xlsx"),
col_types = "text"
)
names(c14dates) <- gsub("\u00E9", "e", names(c14dates))
names(c14occupa) <- gsub("\u00E9", "e", names(c14occupa))
names(c14sites) <- gsub("\u00E9", "e", names(c14sites))
bda <- c14dates %>%
dplyr::left_join(c14sites, by = c("id_site_associe" = "id_sites")) %>%
dplyr::left_join(c14occupa, by = c("id_occupation_liee" = "id_occupations_2019")) %>%
dplyr::transmute(
method = .data[["Methode"]],
labnr = .data[["Code_labo"]],
c14age = .data[["Mesure"]],
c14std = .data[["Ecartype"]],
c13val = .data[["delta13"]],
site = .data[["Nom_site"]],
sitetype = .data[["Nature_site"]],
feature = .data[["num_couche"]],
period = .data[["periode"]],
culture = .data[["culture"]],
material = .data[["Materiel_date"]],
species = .data[["Materiel_date_precision"]],
region = .data[["Region"]],
country = .data[["Pays"]],
lat = .data[["Latitude"]],
lon = .data[["Longitude"]],
shortref = .data[["Ref_biblio"]],
comment = .data[["Fiabilite.x"]],
) %>% dplyr::mutate(
sourcedb = "bda",
sourcedb_version = get_db_version("bda")
) %>%
as.c14_date_list()
return(bda)
}