On Sat, 17 Oct 2020, Artur Tarassow wrote:
Am 16.10.20 um 23:53 schrieb Allin Cottrell:
> I'm not documenting this yet because it needs more testing, but in current
> git I've enabled a new operation on string-valued series: logical product.
> (Snapshots to follow.)
>
> If sv1 and sv2 are string-valued series, then
>
> series sv3 = sv1 * sv2
>
> now yields another string-valued series with value si_sj at observations
> where sv1 has value si and sv2 has value sj.
>
> A simple example is afforded by the R dataset warpbreaks (csv version
> attached). This includes two "factor" series, wool (with values
"A" and
> "B") and tension (with values "L", "M" and
"H").
> If you multiply them together you get a series with 6 distinct values,
> "A_L" to "B_H".
This is pretty useful, Allin! I often face the "problem" that I have two or
more string-valued series which need to be concatenated for creating a unique
identifier before one can set a panel structure.
I concur: this is a very nice idea, very useful, and handled in a very
elegant way. I only have two remarks: a suggestion and a proposal.
(a) we already use the "^" operator for performing what I see as a very
similar operation on lists. It would seem to me more consistent if we used
"^" instead of "*".
(b) why not extend this syntax to string arrays, or even vectors? Imagine
how cool it would be to do something like
<pseudo-hansl>
s = defarray("a", "b")
ss = s ^ seq(1,3)
</pseudo-hansl>
and have ss be a 6-element string array containing "a_1", "a_2" and so
on.
Also, let me go even a step further. A more flexible version may be a
function with three arguments: "sv1", "bridge" and "sv2"
where "bridge" (not
the most ideal parameter name) may be optional allowing for a user-defined
bridging string such as underscore ("_") in the current implementation.
Or perhaps, the "bridge" character could be a libset variable.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------