From f1fe64b4c8d10a6872b35aeb3e528bd4665aac59 Mon Sep 17 00:00:00 2001 From: palatej Date: Thu, 7 Mar 2024 08:30:53 +0100 Subject: [PATCH] Variables --- NAMESPACE | 4 ++++ R/modellingcontext.R | 35 +++++++++++++++++++++++++++++++++++ man/jd3_utilities.Rd | 12 ++++++++++++ 3 files changed, 51 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 7756c217..ef2fafc2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -66,6 +66,7 @@ export(.enum_sextract) export(.enum_sof) export(.jd2p_calendars) export(.jd2p_context) +export(.jd2p_variables) export(.jd2r_calendars) export(.jd2r_lts) export(.jd2r_matrix) @@ -75,11 +76,13 @@ export(.jd2r_ts) export(.jd2r_tscollection) export(.jd2r_tsdata) export(.jd2r_ucarima) +export(.jd2r_variables) export(.jd3_object) export(.jdomain) export(.p2jd_calendar) export(.p2jd_calendars) export(.p2jd_context) +export(.p2jd_variables) export(.p2r_arima) export(.p2r_calendars) export(.p2r_context) @@ -139,6 +142,7 @@ export(.r2jd_ts) export(.r2jd_tscollection) export(.r2jd_tsdata) export(.r2jd_tsdomain) +export(.r2jd_variables) export(.r2p_calendar) export(.r2p_calendars) export(.r2p_context) diff --git a/R/modellingcontext.R b/R/modellingcontext.R index a78e3f68..1c02c4eb 100644 --- a/R/modellingcontext.R +++ b/R/modellingcontext.R @@ -226,6 +226,41 @@ dynamic_ts<-function(moniker, data){ return (l) } +#' @export +#' @rdname jd3_utilities +.p2jd_variables<-function(p){ + bytes<-p$serialize(NULL) + jcal <- .jcall("jdplus/toolkit/base/r/util/Modelling", "Ljdplus/toolkit/base/api/timeseries/regression/TsDataSuppliers;", + "variablesOf", + bytes) + return (jcal) +} + +#' @export +#' @rdname jd3_utilities +.jd2p_variables<-function(jd){ + bytes<-.jcall("jdplus/toolkit/base/r/util/Modelling", "[B", "toBuffer", jd) + p<-RProtoBuf::read(jd3.TsDataSuppliers, bytes) + return (p) +} + + + +#' @export +#' @rdname jd3_utilities +.jd2r_variables<-function(jcals){ + p<-.jd2p_variables(jcals) + return (.p2r_datasuppliers(p)) +} + +#' @export +#' @rdname jd3_utilities +.r2jd_variables<-function(r){ + p<-.r2p_datasuppliers(r) + return (.p2jd_variables(p)) +} + + #' Create context #' @description #' Function allowing to include calendars and external regressors in a format that makes them usable diff --git a/man/jd3_utilities.Rd b/man/jd3_utilities.Rd index 34f91657..5a87fdbd 100644 --- a/man/jd3_utilities.Rd +++ b/man/jd3_utilities.Rd @@ -90,6 +90,10 @@ \alias{.p2r_datasupplier} \alias{.r2p_datasuppliers} \alias{.p2r_datasuppliers} +\alias{.p2jd_variables} +\alias{.jd2p_variables} +\alias{.jd2r_variables} +\alias{.r2jd_variables} \alias{.p2r_context} \alias{.r2p_context} \alias{.p2jd_context} @@ -286,6 +290,14 @@ An object of class \code{Message} of length 3. .p2r_datasuppliers(p) +.p2jd_variables(p) + +.jd2p_variables(jd) + +.jd2r_variables(jcals) + +.r2jd_variables(r) + .p2r_context(p) .r2p_context(r)