title: Function To Split Probabilities :: Error in ans[!test & ok] <- rep(no, length.out = length(ans))[!test & : replacement has length zero
body: <p>I am trying to split probabilities from logistic regression 'glm' model in R into different nominal categories. </p>
  
  <p>I have following function.</p>
  
  <pre><code>nominal_score_test &lt;- function(class_prob) {
               ifelse(class_prob  &gt;= 0.00 &amp; class_prob &lt;= 0.38, '2.Almost Certain',
                  ifelse(class_prob &gt; 0.38 &amp; class_prob &lt;= 0.85, '3.Likely',
                      ifelse(class_prob &gt; 0.85 &amp;  class_prob &lt;= 0.91, '3.Likely',
                          ifelse(class_prob &gt; 0.91 &amp; class_prob &lt;= 1.00, '2.Almost Certain',
                                   NULL
                     ))))
  </code></pre>
  
  <p>}</p>
  
  <p>When I apply this function to a column in a data frame I get an error.</p>
  
  <pre><code>nominal_score_test(estimates_glm_tbl$class_prob)
  
  Error in ans[!test &amp; ok] &lt;- rep(no, length.out = length(ans))[!test &amp; : 
  replacement has length zero
  In addition: Warning message:
  In rep(no, length.out = length(ans)) :    
  </code></pre>
  
  <p>I am really don't understand how I can correct. Any help would be appreciated.</p>
  
  <p>Thanks in advance !!! </p>