r_splice(C;S;D)
Returns a string consisting of a list of elements across a given set of columns, concatenated together using the specified delimiter.
Function type
Vector only
Syntax
r_splice(C;S;D)
Input
Argument | Type | Description |
---|---|---|
C |
any | A space- or comma-separated list of column names
If |
S |
integer | A boolean column or an expression in
rcv_ /rcn_ /rct_ which determines
whether or not that column is selected to be included in the calculation. See System variables for more information about
rcv_ /rcn_ /rct_ .If
|
D |
text | The character to be used as the delimiter in the resultant string. If
A scalar value or the name of a column |
Return Value
For each row of the table, r_splice
returns a text value that consists of
the list of elements in the columns specified by C
delimited by
D
.
Example
Consider the following example:
<table cols="person1, person2, person3, person4" title="r_splice example"> Bob,Carol,Ted,Alice </table> <willbe name="conjunction" value="' and '"/> <willbe name="everyone" value="r_splice('person*';;conjunction)"/> <willbe name="explicitly" value="r_splice(person1 person2 person3 person4;;',')"/> <willbe name="firsttwo" value="r_splice(person1 person2;;conjunction)"/> <willbe name="thewholerow" value="r_splice(;;)"/>
The value of everyone
is the catenation of all the values from the columns
beginning with "person
" (i.e., person1
,
person2
, person3
, and person4
),
delimited by the value in the conjunction
column (i.e., " and
"). The result, therefore, would be:
Bob and Carol and Ted and Alice
The value of explicitly
is the catenation of all the values from the
columns person1
, person2
, person3
, and
person4
, delimited by the character ",
". The result,
therefore, would be:
Bob,Carol,Ted,Alice
The value of firsttwo
is the catenation of all the values from the columns
person1
and person2
, delimited by the value in the
conjunction
column (i.e., " and
"). The result,
therefore, would be:
Bob and Carol
The value of thewholerow
is the catenation of all the values from all of
the columns in the table, with no delimiter. The result, therefore, would be:
BobCarolTedAlice and Bob and Carol and Ted and AliceBob,Carol,Ted,AliceBob and Carol