Skip to content

Commit 0d11dfb

Browse files
authored
Rlabkey v3.4.6: Incorporate new filter types for Array (Multi-value text choice) fields (#124)
- Incorporate new filter types for Array (Multi-value text choice) fields - Update listToMatrix to handle cases where the list elements are an array of strings, which will return a comma separated string in the response
1 parent df59d32 commit 0d11dfb

6 files changed

Lines changed: 48 additions & 7 deletions

File tree

Rlabkey/DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: Rlabkey
2-
Version: 3.4.5
3-
Date: 2026-01-20
2+
Version: 3.4.6
3+
Date: 2026-02-17
44
Title: Data Exchange Between R and 'LabKey' Server
55
Authors@R: c(person(given = "Peter",
66
family = "Hussey",

Rlabkey/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Changes in 3.4.6
2+
o Incorporate new filter types for Array (Multi-value text choice) fields
3+
o Update listToMatrix to handle cases where the list elements are an array of strings, which will return a comma separated string in the response
4+
15
Changes in 3.4.5
26
o Switch to using path first URLs for LabKey server requests.
37
o Utilize httr to generate request query parameters.

Rlabkey/R/makeFilter.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ makeFilter <- function(..., asList=FALSE)
3232
# These operators require a data value
3333
#
3434

35+
# Array-valued column operators
36+
"ARRAY_CONTAINS_ALL"="arraycontainsall",
37+
"ARRAY_CONTAINS_ANY"="arraycontainsany",
38+
"ARRAY_CONTAINS_EXACT"="arraymatches",
39+
"ARRAY_CONTAINS_NOT_EXACT"="arraynotmatches",
40+
"ARRAY_CONTAINS_NONE"="arraycontainsnone",
41+
3542
"EQUALS"="eq",
3643
"EQUAL"="eq",
3744
"DATE_EQUAL"="dateeq",
@@ -90,6 +97,9 @@ makeFilter <- function(..., asList=FALSE)
9097
# These are the "no data value" operators
9198
#
9299

100+
"ARRAY_ISEMPTY"="arrayisempty",
101+
"ARRAY_ISNOTEMPTY"="arrayisnotempty",
102+
93103
"ISBLANK"="isblank",
94104
"IS_MISSING"="isblank",
95105
"MISSING"="isblank",

Rlabkey/man/Rlabkey-package.Rd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ schema objects (\code{labkey.getSchema}).
1818
\tabular{ll}{
1919
Package: \tab Rlabkey\cr
2020
Type: \tab Package\cr
21-
Version: \tab 3.4.5\cr
22-
Date: \tab 2026-01-20\cr
21+
Version: \tab 3.4.6\cr
22+
Date: \tab 2026-02-17\cr
2323
License: \tab Apache License 2.0\cr
2424
LazyLoad: \tab yes\cr
2525
}

Rlabkey/man/makeFilter.Rd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ the column name, operator and value.
2323
}
2424

2525
Operator values:\cr
26+
ARRAY_CONTAINS_ALL\cr
27+
ARRAY_CONTAINS_ANY\cr
28+
ARRAY_CONTAINS_EXACT\cr
29+
ARRAY_CONTAINS_NOT_EXACT\cr
30+
ARRAY_CONTAINS_NONE\cr
31+
ARRAY_ISEMPTY\cr
32+
ARRAY_ISNOTEMPTY\cr
2633
EQUAL\cr
2734
DATE_EQUAL\cr
2835
NOT_EQUAL\cr
@@ -58,7 +65,7 @@ EXP_CHILD_OF\cr
5865
EXP_PARENT_OF\cr
5966
EXP_LINEAGE_OF\cr
6067

61-
When using the MISSING, NOT_MISSING, MV_INDICATOR, or NO_MV_INDICATOR operators, an empty string should be supplied as the value.
68+
When using the MISSING, NOT_MISSING, MV_INDICATOR, NO_MV_INDICATOR, ARRAY_ISEMPTY, or ARRAY_ISNOTEMPTY operators, an empty string should be supplied as the value.
6269
See example below.
6370
}
6471

Rlabkey/src/listToMatrix.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <Rcpp.h>
2+
#include <string>
23
using namespace Rcpp;
34

45
// [[Rcpp::export]]
@@ -35,11 +36,30 @@ CharacterMatrix listToMatrix(List data, List names) {
3536
}
3637
else
3738
{
38-
// only try to parse the first vector element as a string if it is non-null
39+
// only try to parse the vector elements if the first element is not null
3940
GenericVector gv = as<GenericVector>((as<List>(data[i]))[as<int>(indexList[j])]);
4041
if(gv.size() > 0 && !Rf_isNull(gv[0]))
4142
{
42-
cMatrix(i,j) = as<CharacterVector>(gv[0])[0];
43+
// Check if first element is a string - if so, concatenate all elements
44+
if(TYPEOF(gv[0]) == STRSXP)
45+
{
46+
std::string result;
47+
for(int k = 0; k < gv.size(); k++)
48+
{
49+
if(!Rf_isNull(gv[k]) && TYPEOF(gv[k]) == STRSXP)
50+
{
51+
String s = as<String>(gv[k]);
52+
if(k > 0) result += ",";
53+
result += s.get_cstring();
54+
}
55+
}
56+
cMatrix(i,j) = result;
57+
}
58+
else
59+
{
60+
// Fallback to just returning the first element
61+
cMatrix(i,j) = as<CharacterVector>(gv[0])[0];
62+
}
4363
}
4464
}
4565
}

0 commit comments

Comments
 (0)