Skip to content

Commit

Permalink
adjusted the p3k14c parser to use a .csv input file
Browse files Browse the repository at this point in the history
  • Loading branch information
nevrome committed Feb 1, 2022
1 parent 1a334b7 commit c995165
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
20 changes: 11 additions & 9 deletions R/get_p3k14c.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ get_p3k14c <- function(db_url = get_db_url("p3k14c")) {
check_connection_to_url(db_url)

# download and unzip data
temp <- tempfile()
utils::download.file(db_url, temp, quiet = TRUE)
load(temp)

p3k14c_data$d13C[p3k14c_data$d13C == 0.0] <- NA
suppressWarnings(p3k14c_data$d13C <- as.numeric(p3k14c_data$d13C))

p3k14c <- p3k14c_data %>%
p3k14c <- db_url %>%
data.table::fread(
colClasses = "character",
showProgress = FALSE,
na.strings = ""
) %>%
dplyr::mutate(
d13C = suppressWarnings(as.numeric(.data[["d13C"]])),
d13C = ifelse(.data[["d13C"]] == 0, NA, .data[["d13C"]])
) %>%
dplyr::transmute(
labnr = .data[["LabID"]],
c14age = .data[["Age"]],
Expand All @@ -27,7 +29,7 @@ get_p3k14c <- function(db_url = get_db_url("p3k14c")) {
country = .data[["Country"]],
lat = .data[["Lat"]],
lon = .data[["Long"]],
shortref = .data[["Reference"]]
shortref = ifelse(is.na(.data[["Reference"]]), .data[["Source"]], .data[["Reference"]])
) %>%
dplyr::mutate(
sourcedb = "p3k14c",
Expand Down
2 changes: 1 addition & 1 deletion data-raw/db_info_table.csv
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ agrichange,2021-05-21,1,https://zenodo.org/record/4541470/files/AgriChange_14Cda
caribbean,2021-05-21,1,https://raw.githubusercontent.com/philriris/caribbean-14C/main/data/caribbean_14C.csv
aida,today,1,https://raw.githubusercontent.com/apalmisano82/AIDA/main/dates.csv
sard,2021-03-01,1,https://raw.githubusercontent.com/emmaloftus/Southern-African-Radiocarbon-Database/main/SARD_Mar2021_14C.csv
p3k14c,2021-08-03,1,https://github.com/people3k/p3k14c/raw/1.0.0/data/p3k14c_data.rda
p3k14c,2021-08-03,1,https://raw.githubusercontent.com/people3k/p3k14c/1.0.0/inst/p3k14c_scrubbed_fuzzed.csv
3 changes: 1 addition & 2 deletions data-raw/variable_reference.csv
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,4 @@ site,p3k14c,SiteName
country,p3k14c,Country
,p3k14c,Province
region,p3k14c,Continent
,p3k14c,Source
shortref,p3k14c,Reference
shortref,p3k14c,Reference;Source
Binary file modified data/db_info_table.rda
Binary file not shown.

0 comments on commit c995165

Please sign in to comment.