diff --git a/R/cpp11.R b/R/cpp11.R index 5141cfe..4b43411 100644 --- a/R/cpp11.R +++ b/R/cpp11.R @@ -1,7 +1,7 @@ # Generated by cpp11: do not edit by hand -convert_log2_scale_inverse_cpp <- function(dt, vars_to_transform) { - .Call(`_epikinetics_convert_log2_scale_inverse_cpp`, dt, vars_to_transform) +convert_log2_scale_inverse_cpp <- function(dt, vars_to_transform, lower_limit) { + .Call(`_epikinetics_convert_log2_scale_inverse_cpp`, dt, vars_to_transform, lower_limit) } simulate_trajectories_cpp <- function(person_params) { diff --git a/src/convert_log_scale_inverse.cpp b/src/convert_log_scale_inverse.cpp index 7b5fc02..aaa3086 100644 --- a/src/convert_log_scale_inverse.cpp +++ b/src/convert_log_scale_inverse.cpp @@ -4,7 +4,8 @@ using namespace cpp11; [[cpp11::register]] cpp11::data_frame convert_log2_scale_inverse_cpp(cpp11::writable::list dt, - cpp11::strings vars_to_transform) { + cpp11::strings vars_to_transform, + double lower_limit) { for (int i = 0; i < vars_to_transform.size(); i++) { std::string var = vars_to_transform[i]; @@ -13,7 +14,7 @@ cpp11::data_frame convert_log2_scale_inverse_cpp(cpp11::writable::list dt, // Apply the inverse transformation for (int j = 0; j < col.size(); j++) { - col[j] = 2 * pow(2, col[j]); + col[j] = lower_limit * pow(2, col[j]); } // Replace the column diff --git a/src/cpp11.cpp b/src/cpp11.cpp index 18c707b..77022f4 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -6,10 +6,10 @@ #include // convert_log_scale_inverse.cpp -cpp11::data_frame convert_log2_scale_inverse_cpp(cpp11::writable::list dt, cpp11::strings vars_to_transform); -extern "C" SEXP _epikinetics_convert_log2_scale_inverse_cpp(SEXP dt, SEXP vars_to_transform) { +cpp11::data_frame convert_log2_scale_inverse_cpp(cpp11::writable::list dt, cpp11::strings vars_to_transform, double lower_limit); +extern "C" SEXP _epikinetics_convert_log2_scale_inverse_cpp(SEXP dt, SEXP vars_to_transform, SEXP lower_limit) { BEGIN_CPP11 - return cpp11::as_sexp(convert_log2_scale_inverse_cpp(cpp11::as_cpp>(dt), cpp11::as_cpp>(vars_to_transform))); + return cpp11::as_sexp(convert_log2_scale_inverse_cpp(cpp11::as_cpp>(dt), cpp11::as_cpp>(vars_to_transform), cpp11::as_cpp>(lower_limit))); END_CPP11 } // simulate_trajectories.cpp @@ -22,7 +22,7 @@ extern "C" SEXP _epikinetics_simulate_trajectories_cpp(SEXP person_params) { extern "C" { static const R_CallMethodDef CallEntries[] = { - {"_epikinetics_convert_log2_scale_inverse_cpp", (DL_FUNC) &_epikinetics_convert_log2_scale_inverse_cpp, 2}, + {"_epikinetics_convert_log2_scale_inverse_cpp", (DL_FUNC) &_epikinetics_convert_log2_scale_inverse_cpp, 3}, {"_epikinetics_simulate_trajectories_cpp", (DL_FUNC) &_epikinetics_simulate_trajectories_cpp, 1}, {NULL, NULL, 0} };