-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathget_euroevol.R
66 lines (59 loc) · 1.6 KB
/
get_euroevol.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_euroevol <- function(db_url = get_db_url("euroevol")) {
db_url1 <- db_url[1]
db_url2 <- db_url[2]
db_url3 <- db_url[3]
check_connection_to_url(db_url1)
check_connection_to_url(db_url2)
check_connection_to_url(db_url3)
# read dates data
dates <- db_url1 %>%
data.table::fread(
colClasses = "character",
showProgress = FALSE
)
# read site data
sites <- db_url2 %>%
data.table::fread(
sep = ",",
colClasses = "character",
showProgress = FALSE
)
# read phases data
phases <- db_url3 %>%
data.table::fread(
drop = c(
"Subculture"
),
colClasses = "character",
showProgress = FALSE
) %>%
dplyr::select(-.data[["Period"]], -.data[["SiteID"]])
# merge and prepare
euroevol <- dates %>%
# merge
dplyr::left_join(sites, by = "SiteID") %>%
dplyr::left_join(phases, by = "PhaseCode") %>%
base::replace(., . == "NULL", NA) %>%
base::replace(., . == "", NA) %>%
dplyr::transmute(
labnr = .data[["LabCode"]],
c14age = .data[["C14Age"]],
c14std = .data[["C14SD"]],
material = .data[["Material"]],
species = .data[["MaterialSpecies"]],
country = .data[["Country"]],
lat = .data[["Latitude"]],
lon = .data[["Longitude"]],
site = .data[["SiteName"]],
period = .data[["Period"]],
culture = .data[["Culture"]],
sitetype = .data[["Type"]]
) %>% dplyr::mutate(
sourcedb = "euroevol",
sourcedb_version = get_db_version("euroevol")
) %>%
as.c14_date_list()
return(euroevol)
}