The problem prompting this arises from a table I imported into JMP. JMP imports a column of TRUE/FALSE as Character type. I want to combine this with other logical/boolean calculations, so for example:
:TRUEFALSEcolumn & :NumericValue>100
However, the Boolean operators are designed to work only with numeric data (I understand why). I went looking for a JSL equivalent to R's as.logical() function and came across JSL's As Boolean().
After interaction with Tech Support (see track referenced by tracking number here) I understand As Boolean() was created to support JMP's ability to handle JSON files. I think there is more potential here and would like to see As Boolean()'s output supported in the Boolean operators like And(), Or(), and Not().
Yes, a valid workaround is a Match() statement to convert the character "FALSE" to numeric 0, character "TRUE" to numeric 1. It's just not as concise and easy-to-read as As Boolean(:TRUEFALSEcolumn) would be and is a nuance in the JSL language that is not straightforward to statisticians coming at a problem with knowledge of the larger stat programming languages. Adding the capability would be convenient. Admittedly not a high priority.
Some of us were looking at this issue recently. The issue still exists as you reported here, but i wanted to share a workaround which is still easier than a Match() statement.
as boolean("TRUE")>0 & 100>99; //AND
as boolean("False")>0 & 100>99; //OR
//example table
New Table( "example AsBoolean",
Add Rows( 4 ),
New Column( "TrueFalseCol", Character, "Nominal",
Set Values( {"True", "False", "True", "False"} )
),
New Column( "value", Numeric, "Continuous",
Set Values( [100, 100, 50, 50] )
),
New Column( "product", Numeric, "Continuous",
Formula( As Boolean( :TrueFalseCol ) * :value )
),
New Column( "AND", Numeric, "Continuous",
Formula( and(As Boolean( :TrueFalseCol )>0, :value) )
),
New Column( "OR", Numeric, "Continuous",
Formula( or(As Boolean( :TrueFalseCol )>0, :value) )
),
New Column( "NOT", Numeric, "Continuous",
Formula( Not(As Boolean( :TrueFalseCol )>0) )
)
);
Fascinating. I understand it but don't really find it to be intuitive. So there's still room for improvement, but at least this helps.