title: Convert "character" matrix to "logical"
body: <p>I have a matrix (with values of <code>class</code> <code>character</code> like this one:</p>
  
  <pre><code>mat &lt;- matrix(c("0", "TRUE", "1", "2",
                  "FALSE", "TRUE", "TRUE", "2"), nrow = 4, ncol = 2)
  #&gt; mat
  #     [,1]   [,2]   
  #[1,] "0"    "FALSE"
  #[2,] "TRUE" "TRUE" 
  #[3,] "1"    "TRUE" 
  #[4,] "2"    "2"  
  </code></pre>
  
  <p>and I need to convert it to a matrix like this:</p>
  
  <pre><code>      [,1]  [,2]
  [1,] FALSE FALSE
  [2,]  TRUE  TRUE
  [3,]  TRUE  TRUE
  [4,]  TRUE  TRUE
  </code></pre>
  
  <p><code>as.logical</code> outputs <code>NA</code>s to "character-numeric" values, whereas <code>as.numeric</code> outputs <code>NA</code>s to "character-logical" values.</p>
  
  <p>I found a solution but I think I'm missing something clearly obvious as to an immediate conversion:</p>
  
  <pre><code>new_mat2 &lt;- array(as.numeric(mat), dim(mat))
  new_mat &lt;- array(as.logical(mat), dim(mat))
  
  new_mat[is.na(new_mat)] &lt;- new_mat2[is.na(new_mat)]
  mat2 &lt;- array(as.logical(new_mat), dim(new_mat))
  
  #&gt; mat2
  #      [,1]  [,2]
  #[1,] FALSE FALSE
  #[2,]  TRUE  TRUE
  #[3,]  TRUE  TRUE
  #[4,]  TRUE  TRUE
  </code></pre>
  
  <p>Any suggestions?</p>