On Wed, Feb 1, 2023 at 5:02 AM Paolo Chirico <paolo.chirico(a)uniupo.it> wrote:
Dears,
If I have a string variable with the following mapping:
1 = 'middle'
2 = 'low'
3 = 'high'
there is a command to give the series a new, more logical mapping? Like as:
1 = 'low'
2 = 'middle'
3 = 'high'
I've simplified the example, but the concept is: changing the numerical
mapping of the entire series
Here's my take on this. Suppose we have a file strs.csv with this content:
<csv>
x
middle
low
high
high
low
middle
</csv>
Then we can process it in this way:
<hansl>
open strs.csv
series numx = x
series y = x
# swap numerical values 1 and 2
series y = y==1 ? 2 : y==2 ? 1 : y
# add strings in 'logical' order
stringify(y, defarray("low", "middle", "high"))
series numy = y
print -o
</hansl>
(The "num*" series are added just to expose the numeric codings.)
Allin