-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathget_katsianis.R
69 lines (61 loc) · 1.62 KB
/
get_katsianis.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
#' @rdname db_getter_backend
#' @export
get_katsianis <- function(db_url = get_db_url("katsianis")) {
check_connection_to_url(db_url)
# download and unzip data
temp <- tempfile(fileext = ".zip")
utils::download.file(
db_url,
temp,
mode="wb",
quiet = TRUE
)
unzip_path <- file.path(tempdir(), "c14bazAAR_get_katsianis")
db_path <- utils::unzip(
temp,
exdir = unzip_path
)
# read data
katsianis <- data.table::fread(
db_path[grepl("/C14Samples.txt", db_path)],
sep = "\t",
drop = c(
"DBID",
"OthLabID",
"OthDateCode",
"Problems",
"OthMeasures"
),
colClasses = "character",
showProgress = FALSE
) %>%
base::replace(., . == "", NA) %>%
dplyr::transmute(
labnr = .data[["LabID"]],
c14age = .data[["CRA"]],
c14std = .data[["Error"]],
c13val = .data[["DC13"]],
method = .data[["DateMethod"]],
material = .data[["Material"]],
species = .data[["Species"]],
site = .data[["SiteName"]],
sitetype = .data[["SiteType"]],
region = .data[["AdminRegion"]],
country = .data[["Country"]],
feature = .data[["SiteContext"]],
period = .data[["SitePhase"]],
culture = .data[["CulturalPeriod"]],
lat = .data[["Latitude"]],
lon = .data[["Longitude"]],
shortref = .data[["Source"]],
comment = .data[["Comments"]]
) %>% dplyr::mutate(
sourcedb = "katsianis",
sourcedb_version = get_db_version("katsianis")
) %>%
as.c14_date_list()
# remove files in file system
unlink(temp)
unlink(unzip_path, recursive = T)
return(katsianis)
}