title: Output a boolean from an Rscript into a Bash variable
body: <p>I have an R script that outputs TRUE or FALSE.  In R, it's using a bona fide T/F data type, but when I echo its return value to bash, it seems to be a string, saying:</p>
  <p><code>&quot;[1] TRUE&quot;</code></p>
  <p>or</p>
  <p><code>&quot;[1] FALSE&quot;</code></p>
  <p>They are both preceded by [1].  Neither is [0], that is not a typo.  Anyway, the result of this is what when I try to test on the output of this Rscript to run a subsequent script, I have to do string comparison to &quot;[1] TRUE&quot; as below, instead of comparing to &quot;TRUE&quot; or &quot;1&quot; which feels cleaner and better.</p>
  <pre><code>A=$(Rscript ~/MyR.r)
  echo $A
  if [ &quot;$A&quot; == &quot;[1] TRUE&quot; ]; then
      bash SecondScript.sh
  fi
  </code></pre>
  <p>How can I make R either output a true Boolean, or Bash accept the output string and convert it to 0/1 for comparison?  That is, I'd rather test for...</p>
  <pre><code>if [ $A == TRUE ];
  </code></pre>
  <p>than</p>
  <pre><code>if [ &quot;$A&quot; == &quot;[1] TRUE&quot; ];
  </code></pre>
  <p>Is that possible, or should I be happy with this, how it is, which works?</p>
  <p>*** UPDATE ***</p>
  <p>Here's the minimalized version of the Rscript that generates this...</p>
  <pre><code>myinput &lt;- TRUE #or FALSE
  
  FunctionName &lt;- function(test){
    if (test == TRUE){
      val &lt;- TRUE
    } else {
      val &lt;- FALSE
    }
    return(val)
  }
  
  FunctionName(myinput)
  </code></pre>