From 781132500471a9d55a1f1a1d37475d1063f37e8e Mon Sep 17 00:00:00 2001 From: Nick Christofides <118103879+NicChr@users.noreply.github.com> Date: Wed, 17 Apr 2024 09:20:14 +0200 Subject: [PATCH] Removing repetitive declarations. --- R/lag.R | 2 +- man/lag_.Rd | 2 +- src/attrs.cpp | 2 -- src/cheapr_cpp.h | 3 +++ src/gcd.cpp | 2 -- src/lag.cpp | 2 -- src/nas.cpp | 2 -- src/sequences.cpp | 2 -- src/set_math.cpp | 2 -- src/sset.cpp | 2 -- src/utils.cpp | 2 -- src/which.cpp | 2 -- 12 files changed, 5 insertions(+), 20 deletions(-) diff --git a/R/lag.R b/R/lag.R index 86e1f63..cf679d2 100644 --- a/R/lag.R +++ b/R/lag.R @@ -3,7 +3,7 @@ #' @description #' Fast lags and leads #' -#' @param x A vector. +#' @param x A vector or data frame. #' @param n Number of lags. Negative values are accepted. #' @param fill Value used to fill first n values. Default is `NA`. #' @param set Should x be updated by reference? If `TRUE` no copy is made and diff --git a/man/lag_.Rd b/man/lag_.Rd index 0e06c20..0e84999 100644 --- a/man/lag_.Rd +++ b/man/lag_.Rd @@ -7,7 +7,7 @@ lag_(x, n = 1, fill = NULL, set = FALSE, recursive = TRUE) } \arguments{ -\item{x}{A vector.} +\item{x}{A vector or data frame.} \item{n}{Number of lags. Negative values are accepted.} diff --git a/src/attrs.cpp b/src/attrs.cpp index 206d9a5..97743a2 100644 --- a/src/attrs.cpp +++ b/src/attrs.cpp @@ -1,6 +1,4 @@ #include "cheapr_cpp.h" -#include -#include // Adding and removing attributes in-place // There is a check to ensure that attributes are copied when they are the same diff --git a/src/cheapr_cpp.h b/src/cheapr_cpp.h index 00262c4..c9b5bc9 100644 --- a/src/cheapr_cpp.h +++ b/src/cheapr_cpp.h @@ -4,7 +4,10 @@ #ifndef cheapr_cpp_funs #define cheapr_cpp_funs +#ifndef R_NO_REMAP #define R_NO_REMAP +#endif + #define VECTOR_PTR(x) ((SEXP *) DATAPTR(x)) #define VECTOR_PTR_RO(x) ((const SEXP*) DATAPTR_RO(x)) diff --git a/src/gcd.cpp b/src/gcd.cpp index a7d5eec..27823b2 100644 --- a/src/gcd.cpp +++ b/src/gcd.cpp @@ -1,6 +1,4 @@ #include "cheapr_cpp.h" -#include -#include [[cpp11::register]] double cpp_gcd2(double x, double y, double tol, bool na_rm){ diff --git a/src/lag.cpp b/src/lag.cpp index ef8c9e7..fd4d7b6 100644 --- a/src/lag.cpp +++ b/src/lag.cpp @@ -1,6 +1,4 @@ #include "cheapr_cpp.h" -#include -#include [[cpp11::register]] SEXP cpp_lag(SEXP x, int k, SEXP fill, bool set, bool recursive) { diff --git a/src/nas.cpp b/src/nas.cpp index 44ae359..414b7ea 100644 --- a/src/nas.cpp +++ b/src/nas.cpp @@ -1,6 +1,4 @@ #include "cheapr_cpp.h" -#include -#include R_xlen_t na_count(SEXP x, bool recursive){ R_xlen_t n = Rf_xlength(x); diff --git a/src/sequences.cpp b/src/sequences.cpp index e3de44c..426d4af 100644 --- a/src/sequences.cpp +++ b/src/sequences.cpp @@ -1,6 +1,4 @@ #include "cheapr_cpp.h" -#include -#include double r_sum(SEXP x, bool na_rm = false){ cpp11::function base_sum = cpp11::package("base")["sum"]; diff --git a/src/set_math.cpp b/src/set_math.cpp index 752c7cd..4e7c7e7 100644 --- a/src/set_math.cpp +++ b/src/set_math.cpp @@ -1,6 +1,4 @@ #include "cheapr_cpp.h" -#include -#include // Basic math operations by reference // All NA and NaN values are ignored diff --git a/src/sset.cpp b/src/sset.cpp index 5190ab6..4902c0b 100644 --- a/src/sset.cpp +++ b/src/sset.cpp @@ -1,6 +1,4 @@ #include "cheapr_cpp.h" -#include -#include // #include // using namespace cpp11; diff --git a/src/utils.cpp b/src/utils.cpp index 61627f6..4a8e1a3 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,6 +1,4 @@ #include "cheapr_cpp.h" -#include -#include int int_div(int x, int y){ return x / y; diff --git a/src/which.cpp b/src/which.cpp index f712c8d..5bde1f6 100644 --- a/src/which.cpp +++ b/src/which.cpp @@ -1,6 +1,4 @@ #include "cheapr_cpp.h" -#include -#include // A more memory-efficient which() // Author: Nick Christofides