From 0ec2dc1ce8cfe34e234cfba2ed6afa621281e456 Mon Sep 17 00:00:00 2001 From: Niklas Hohmann <67792281+NiklasHohmann@users.noreply.github.com> Date: Thu, 12 Sep 2024 07:59:21 +0200 Subject: [PATCH 1/3] add example --- R/is_adm.R | 7 +++++++ man/is_adm.Rd | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/R/is_adm.R b/R/is_adm.R index ca49a48..50e0b5a 100644 --- a/R/is_adm.R +++ b/R/is_adm.R @@ -15,6 +15,13 @@ is_adm = function(x, quietly = TRUE){ #' #' @returns logical. Is the input a valid adm object? #' + #' + #' @examples + #' + #' x = tp_to_adm(t = c(2,1), h = c(1,2)) # reversed order of time tie points + #' is_adm(x) # returns FALSE + #' + #' warning_status = getOption("warn") diff --git a/man/is_adm.Rd b/man/is_adm.Rd index aa28414..89c09a2 100644 --- a/man/is_adm.Rd +++ b/man/is_adm.Rd @@ -18,3 +18,10 @@ logical. Is the input a valid adm object? Contructors for adm objects such as \emph{tp_to_adm} do not check whether the inputs define a valid age-depth mode, e.g. one where the law of superposition holds. This function performs these checks } +\examples{ + +x = tp_to_adm(t = c(2,1), h = c(1,2)) # reversed order of time tie points +is_adm(x) # returns FALSE + + +} From 00b57ff15271ec338c0622456b51204d10df0423 Mon Sep 17 00:00:00 2001 From: Niklas Hohmann <67792281+NiklasHohmann@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:52:23 +0200 Subject: [PATCH 2/3] add transformation of S3 class pre_paleoTS --- NAMESPACE | 2 ++ NEWS.md | 2 ++ R/strat_to_time.pre_paleoTS.R | 20 ++++++++++++++++++++ R/time_to_strat.pre_paleoTS.R | 18 ++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 R/strat_to_time.pre_paleoTS.R create mode 100644 R/time_to_strat.pre_paleoTS.R diff --git a/NAMESPACE b/NAMESPACE index 191a55b..7997d31 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -67,12 +67,14 @@ S3method(set_T_unit,sac) S3method(strat_to_time,list) S3method(strat_to_time,numeric) S3method(strat_to_time,phylo) +S3method(strat_to_time,pre_paleoTS) S3method(summary,adm) S3method(summary,multiadm) S3method(summary,sac) S3method(time_to_strat,list) S3method(time_to_strat,numeric) S3method(time_to_strat,phylo) +S3method(time_to_strat,pre_paleoTS) export(L_axis_lab) export(T_axis_lab) export(add_adm_to_multiadm) diff --git a/NEWS.md b/NEWS.md index feb900e..a605c58 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # admtools (development version) +* added transformations for S3 class `pre_paleoTS` to integrate with `StratPal` and `paleoTS` package + * added anchoring of age-depth models via `anchor` # admtools 0.3.1 diff --git a/R/strat_to_time.pre_paleoTS.R b/R/strat_to_time.pre_paleoTS.R new file mode 100644 index 0000000..b359192 --- /dev/null +++ b/R/strat_to_time.pre_paleoTS.R @@ -0,0 +1,20 @@ +strat_to_time.pre_paleoTS = function(obj, x, ...){ + #' @export + #' + + li = obj + adm = x + + if (! "h" %in% names(li)){ + stop("no stratigraphic information found. Expected element with name \"h\" in list") + } + if ("t" %in% names(li)){ + warning("Found element with name \"t\" in list. Temporal information will be overwritten") + } + + li[["t"]] = get_time(adm, h = li[["h"]], ...) + li = li[names(li) != "h" ] + class(li) = c("pre_paleoTS" ,"timelist", "list") + return(li) + +} \ No newline at end of file diff --git a/R/time_to_strat.pre_paleoTS.R b/R/time_to_strat.pre_paleoTS.R new file mode 100644 index 0000000..71ee03b --- /dev/null +++ b/R/time_to_strat.pre_paleoTS.R @@ -0,0 +1,18 @@ +time_to_strat.pre_paleoTS = function(obj, x, ...){ + #' @export + + li = obj + adm = x + + if (! "t" %in% names(li)){ + stop("no time information found. Expected element with name \"t\"") + } + if ("h" %in% names(li)){ + warning("Found element with name \"h\" in list. Height information will be overwritten") + } + + li[["h"]] = get_height(adm, t = li[["t"]], ...) + li = li[names(li) != "t" ] + class(li) = c("pre_paleoTS" , "stratlist", "list") + return(li) +} \ No newline at end of file From 8c7911557b639ae97b26bd18779392f38b52921c Mon Sep 17 00:00:00 2001 From: Niklas Hohmann <67792281+NiklasHohmann@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:59:35 +0200 Subject: [PATCH 3/3] increment dev version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5ff130d..3fc7bc9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: admtools Title: Estimate and Manipulate Age-Depth Models -Version: 0.3.1.9000 +Version: 0.3.1.9001 Authors@R: person("Niklas", "Hohmann", , "N.H.Hohmann@uu.nl", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1559-1838"))