forked from ropensci/c14bazAAR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_14cpalaeolithic.R
52 lines (44 loc) · 1.42 KB
/
get_14cpalaeolithic.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
#' @rdname db_getter_backend
#' @export
get_14cpalaeolithic <- function(db_url = get_db_url("14cpalaeolithic")) {
# db_url <- "https://ees.kuleuven.be/geography/projects/14c-palaeolithic/radiocarbon-palaeolithic-europe-database-v26-extract.xlsx"
check_connection_to_url(db_url)
# download data
temp <- tempfile(fileext = ".xlsx")
utils::download.file(url = db_url, destfile = temp, mode = "wb", quiet = TRUE)
# read data
db_raw <- openxlsx::read.xlsx(
temp,
sheet = 1
) %>%
dplyr::mutate_if(
sapply(., is.character),
trimws
)
# remove files in file system
unlink(temp)
# final data preparation
c14palaeolithic <- db_raw %>%
base::replace(., . == "", NA) %>%
dplyr::transmute(
method = .data[["method"]],
labnr = .data[["labref"]],
c14age = .data[["age"]],
c14std = .data[["sigma.+/-"]],
site = .data[["sitename"]],
period = .data[["cult.stage"]],
material = .data[["sample"]],
country = .data[["country"]],
lat = .data[["coord_lat"]],
lon = .data[["coord_long"]],
shortref = .data[["bibliogr_ref"]]
) %>% dplyr::mutate(
sourcedb = "14cpalaeolithic",
sourcedb_version = get_db_version("14cpalaeolithic")
) %>%
as.c14_date_list()
# remove non-radiocarbon dates
c14palaeolithic <- c14palaeolithic %>%
dplyr::filter(.data[["method"]] %in% c("AMS", "Conv. 14C"))
return(c14palaeolithic)
}