From 2d218e768467f87aa8f4fa07c0df4ac29c331019 Mon Sep 17 00:00:00 2001 From: 2005m Date: Thu, 25 Apr 2024 19:15:07 +0100 Subject: [PATCH] Fixes and changes --- DESCRIPTION | 4 +-- R/call.R | 2 +- inst/NEWS.Rd | 13 ++++++++ src/dup.c | 2 +- src/dupLen.c | 2 +- src/fpos.c | 2 +- src/iif.c | 2 +- src/nswitch.c | 72 ++++++++++++++++++++-------------------- src/psort.c | 2 +- src/psum.c | 2 +- src/share.c | 2 +- src/topn.c | 2 +- src/utils.c | 2 +- src/vswitch.c | 2 +- tests/test_kit.R | 6 ++++ tests/test_kit.Rout.save | 6 ++++ 16 files changed, 74 insertions(+), 49 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 662b3b1..42aafed 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: kit Type: Package Title: Data Manipulation Functions Implemented in C -Version: 0.0.16 -Date: 2024-03-01 +Version: 0.0.17 +Date: 2024-04-25 Authors@R: c(person("Morgan", "Jacob", role = c("aut", "cre", "cph"), email = "morgan.emailbox@gmail.com"), person("Sebastian", "Krantz", role = "ctb")) Author: Morgan Jacob [aut, cre, cph], Sebastian Krantz [ctb] diff --git a/R/call.R b/R/call.R index 47bed43..de7ca89 100644 --- a/R/call.R +++ b/R/call.R @@ -33,7 +33,7 @@ vswitch = function(x, values, outputs, default=NULL, nThread=getOption("kit. omp = if(.Call(CompEnabledR)) "enabled" else "disabled" #nocov nth = getOption("kit.nThread") #nocov thd = if (nth > 1L) " threads)" else " thread)" #nocov - packageStartupMessage(paste0("Attaching kit 0.0.16 (OPENMP ",omp," using ",nth,thd)) #nocov + packageStartupMessage(paste0("Attaching kit 0.0.17 (OPENMP ",omp," using ",nth,thd)) #nocov } #nocov .onLoad = function(libname, pkgname) { #nocov diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index b3da689..6ceefcb 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -4,6 +4,19 @@ \newcommand{\CRANpkg}{\href{https://CRAN.R-project.org/package=#1}{\pkg{#1}}} +\section{version 0.0.17 (2024-04-25)}{ + \subsection{Bug Fixes}{ + \itemize{ + \item Fix \code{nswitch}. Thanks to Sebastian Krantz for raising an issue. + } + } + \subsection{Notes}{ + \itemize{ + \item Update copyright date in c files + } + } +} + \section{version 0.0.16 (2024-03-01)}{ \subsection{Notes}{ \itemize{ diff --git a/src/dup.c b/src/dup.c index 4a91fc5..d6c8ef2 100644 --- a/src/dup.c +++ b/src/dup.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/dupLen.c b/src/dupLen.c index 8127349..e2e7d3e 100644 --- a/src/dupLen.c +++ b/src/dupLen.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/fpos.c b/src/fpos.c index 4ac5e11..b993b05 100644 --- a/src/fpos.c +++ b/src/fpos.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/iif.c b/src/iif.c index 72e6718..71a90ef 100644 --- a/src/iif.c +++ b/src/iif.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/nswitch.c b/src/nswitch.c index dbbe528..c2baa83 100644 --- a/src/nswitch.c +++ b/src/nswitch.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -151,7 +151,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = LOGICAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -164,7 +164,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = INTEGER(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -177,7 +177,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const double *restrict pvalues = REAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -190,7 +190,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const Rcomplex *restrict pvalues = COMPLEX(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (EQUAL_CPLX(px[j], pvalues[0])) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -203,7 +203,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -244,7 +244,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = LOGICAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -257,7 +257,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = INTEGER(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -270,7 +270,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const double *restrict pvalues = REAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -283,7 +283,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const Rcomplex *restrict pvalues = COMPLEX(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (EQUAL_CPLX(px[j], pvalues[0])) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -296,7 +296,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -308,7 +308,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = SEXPPTR_RO(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (R_compute_identical(px[j],pvalues[0],0)) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -337,7 +337,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = LOGICAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -350,7 +350,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = INTEGER(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -363,7 +363,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const double *restrict pvalues = REAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -376,7 +376,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const Rcomplex *restrict pvalues = COMPLEX(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (EQUAL_CPLX(px[j], pvalues[0])) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -389,7 +389,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -401,7 +401,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = SEXPPTR_RO(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (R_compute_identical(px[j],pvalues[0],0)) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -431,7 +431,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = LOGICAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -444,7 +444,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = INTEGER(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -457,7 +457,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const double *restrict pvalues = REAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -470,7 +470,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const Rcomplex *restrict pvalues = COMPLEX(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (EQUAL_CPLX(px[j],pvalues[0])) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -483,7 +483,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -495,7 +495,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = SEXPPTR_RO(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (R_compute_identical(px[j],pvalues[0],0)) { - pans[j] = pto[i & amask[i]]; + pans[j] = pto[j & amask[i]]; } } } @@ -521,7 +521,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = LOGICAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - SET_STRING_ELT(ans, j, pto[i & amask[i]]); + SET_STRING_ELT(ans, j, pto[j & amask[i]]); } } } @@ -533,7 +533,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = INTEGER(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - SET_STRING_ELT(ans, j, pto[i & amask[i]]); + SET_STRING_ELT(ans, j, pto[j & amask[i]]); } } } @@ -545,7 +545,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const double *restrict pvalues = REAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - SET_STRING_ELT(ans, j, pto[i & amask[i]]); + SET_STRING_ELT(ans, j, pto[j & amask[i]]); } } } @@ -557,7 +557,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const Rcomplex *restrict pvalues = COMPLEX(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (EQUAL_CPLX(px[j],pvalues[0])) { - SET_STRING_ELT(ans, j, pto[i & amask[i]]); + SET_STRING_ELT(ans, j, pto[j & amask[i]]); } } } @@ -569,7 +569,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - SET_STRING_ELT(ans, j, pto[i & amask[i]]); + SET_STRING_ELT(ans, j, pto[j & amask[i]]); } } } @@ -581,7 +581,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = SEXPPTR_RO(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (R_compute_identical(px[j],pvalues[0],0)) { - SET_STRING_ELT(ans, j, pto[i & amask[i]]); + SET_STRING_ELT(ans, j, pto[j & amask[i]]); } } } @@ -609,7 +609,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = LOGICAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - SET_VECTOR_ELT(ans, j, pto[i & amask[i]]); + SET_VECTOR_ELT(ans, j, pto[j & amask[i]]); } } } @@ -621,7 +621,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const int *restrict pvalues = INTEGER(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - SET_VECTOR_ELT(ans, j, pto[i & amask[i]]); + SET_VECTOR_ELT(ans, j, pto[j & amask[i]]); } } } @@ -633,7 +633,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const double *restrict pvalues = REAL(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - SET_VECTOR_ELT(ans, j, pto[i & amask[i]]); + SET_VECTOR_ELT(ans, j, pto[j & amask[i]]); } } } @@ -645,7 +645,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const Rcomplex *restrict pvalues = COMPLEX(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (EQUAL_CPLX(px[j], pvalues[0])) { - SET_VECTOR_ELT(ans, j, pto[i & amask[i]]); + SET_VECTOR_ELT(ans, j, pto[j & amask[i]]); } } } @@ -657,7 +657,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = STRING_PTR(utfcon ? vans : PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (px[j] == pvalues[0]) { - SET_VECTOR_ELT(ans, j, pto[i & amask[i]]); + SET_VECTOR_ELT(ans, j, pto[j & amask[i]]); } } } @@ -669,7 +669,7 @@ SEXP nswitchR(SEXP x, SEXP na, SEXP nthreads, SEXP chkenc, SEXP args) { const SEXP *restrict pvalues = SEXPPTR_RO(PTR_ETL(args, 2*i)); for (ssize_t j = 0; j < len_x; ++j) { if (R_compute_identical(px[j],pvalues[0],0)) { - SET_VECTOR_ELT(ans, j, pto[i & amask[i]]); + SET_VECTOR_ELT(ans, j, pto[j & amask[i]]); } } } diff --git a/src/psort.c b/src/psort.c index c7c36d3..e6083f4 100644 --- a/src/psort.c +++ b/src/psort.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/psum.c b/src/psum.c index 12994d0..86a03e7 100644 --- a/src/psum.c +++ b/src/psum.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/share.c b/src/share.c index cb9be74..72d3608 100644 --- a/src/share.c +++ b/src/share.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/topn.c b/src/topn.c index bd7d8a9..92028f3 100644 --- a/src/topn.c +++ b/src/topn.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/utils.c b/src/utils.c index a7dde1d..3144bab 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/vswitch.c b/src/vswitch.c index 2102325..1474b98 100644 --- a/src/vswitch.c +++ b/src/vswitch.c @@ -1,6 +1,6 @@ /* * kit : Useful R Functions Implemented in C - * Copyright (C) 2020-2021 Morgan Jacob + * Copyright (C) 2020-2024 Morgan Jacob * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/tests/test_kit.R b/tests/test_kit.R index b76c236..b0e0ec1 100644 --- a/tests/test_kit.R +++ b/tests/test_kit.R @@ -1547,6 +1547,12 @@ check("0019.061", nswitch(c(enc1,enc1),enc1,1),c(1,1)) check("0019.062", nswitch(c(enc2,enc2),enc2,1),c(1,1)) check("0019.063", nswitch(c(enc1,enc2),enc2,1),c(1,1)) check("0019.064", nswitch(c(enc1,enc1),enc2,1),c(1,1)) +check("0019.065", nswitch(rep(1:4, each = 2), 1L, 1:8, 2L, 11:18, 3L, 21:28, 4L, 31:38), vswitch(x = rep(1:4, each = 2), values = c(1L,2L,3L,4L), outputs = list(1:8,11:18,21:28,31:38))) +check("0019.066", nswitch(rep(1:4, each = 2), 1L, as.numeric(1:8), 2L, as.numeric(11:18), 3L, as.numeric(21:28), 4L, as.numeric(31:38)), vswitch(x = rep(1:4, each = 2), values = c(1L,2L,3L,4L), outputs = list(as.numeric(1:8),as.numeric(11:18),as.numeric(21:28),as.numeric(31:38)))) +check("0019.067", nswitch(rep(1:4, each = 2), 1L, as.character(1:8), 2L, as.character(11:18), 3L, as.character(21:28), 4L, as.character(31:38)), vswitch(x = rep(1:4, each = 2), values = c(1L,2L,3L,4L), outputs = list(as.character(1:8),as.character(11:18),as.character(21:28),as.character(31:38)))) +check("0019.068", nswitch(rep(as.numeric(1:4), each = 2), 1, 1:8, 2, 11:18, 3, 21:28, 4, 31:38), vswitch(x = rep(as.numeric(1:4), each = 2), values = c(1,2,3,4), outputs = list(1:8,11:18,21:28,31:38))) +check("0019.069", nswitch(rep(as.numeric(1:4), each = 2), 1, as.numeric(1:8), 2, as.numeric(11:18), 3, as.numeric(21:28), 4, as.numeric(31:38)), vswitch(x = rep(as.numeric(1:4), each = 2), values = c(1,2,3,4), outputs = list(as.numeric(1:8),as.numeric(11:18),as.numeric(21:28),as.numeric(31:38)))) +check("0019.070", nswitch(rep(as.numeric(1:4), each = 2), 1, as.character(1:8), 2, as.character(11:18), 3, as.character(21:28), 4, as.character(31:38)), vswitch(x = rep(as.numeric(1:4), each = 2), values = c(1,2,3,4), outputs = list(as.character(1:8),as.character(11:18),as.character(21:28),as.character(31:38)))) rm(x1,x2,x3,x4,x5,x6,s1,s2,class2133, enc1, enc2) diff --git a/tests/test_kit.Rout.save b/tests/test_kit.Rout.save index 0009199..aa6aee3 100644 --- a/tests/test_kit.Rout.save +++ b/tests/test_kit.Rout.save @@ -1566,6 +1566,12 @@ Type 'q()' to quit R. > check("0019.062", nswitch(c(enc2,enc2),enc2,1),c(1,1)) > check("0019.063", nswitch(c(enc1,enc2),enc2,1),c(1,1)) > check("0019.064", nswitch(c(enc1,enc1),enc2,1),c(1,1)) +> check("0019.065", nswitch(rep(1:4, each = 2), 1L, 1:8, 2L, 11:18, 3L, 21:28, 4L, 31:38), vswitch(x = rep(1:4, each = 2), values = c(1L,2L,3L,4L), outputs = list(1:8,11:18,21:28,31:38))) +> check("0019.066", nswitch(rep(1:4, each = 2), 1L, as.numeric(1:8), 2L, as.numeric(11:18), 3L, as.numeric(21:28), 4L, as.numeric(31:38)), vswitch(x = rep(1:4, each = 2), values = c(1L,2L,3L,4L), outputs = list(as.numeric(1:8),as.numeric(11:18),as.numeric(21:28),as.numeric(31:38)))) +> check("0019.067", nswitch(rep(1:4, each = 2), 1L, as.character(1:8), 2L, as.character(11:18), 3L, as.character(21:28), 4L, as.character(31:38)), vswitch(x = rep(1:4, each = 2), values = c(1L,2L,3L,4L), outputs = list(as.character(1:8),as.character(11:18),as.character(21:28),as.character(31:38)))) +> check("0019.068", nswitch(rep(as.numeric(1:4), each = 2), 1, 1:8, 2, 11:18, 3, 21:28, 4, 31:38), vswitch(x = rep(as.numeric(1:4), each = 2), values = c(1,2,3,4), outputs = list(1:8,11:18,21:28,31:38))) +> check("0019.069", nswitch(rep(as.numeric(1:4), each = 2), 1, as.numeric(1:8), 2, as.numeric(11:18), 3, as.numeric(21:28), 4, as.numeric(31:38)), vswitch(x = rep(as.numeric(1:4), each = 2), values = c(1,2,3,4), outputs = list(as.numeric(1:8),as.numeric(11:18),as.numeric(21:28),as.numeric(31:38)))) +> check("0019.070", nswitch(rep(as.numeric(1:4), each = 2), 1, as.character(1:8), 2, as.character(11:18), 3, as.character(21:28), 4, as.character(31:38)), vswitch(x = rep(as.numeric(1:4), each = 2), values = c(1,2,3,4), outputs = list(as.character(1:8),as.character(11:18),as.character(21:28),as.character(31:38)))) > > rm(x1,x2,x3,x4,x5,x6,s1,s2,class2133, enc1, enc2) >