title: Applying conditional statements to all elements in a dataframe using R
body: <p>I have a dataframe that looks like this-</p>
  
  <pre><code>&gt; dpd
           md       mean         sd       fsf        dii   n
  2      77.5 0.02827206 0.05761423 0.8382353  29.648895 136
  3     120.0 0.07058824 0.04696682 0.5882353   8.333333  17
  NA       NA         NA         NA        NA         NA  NA
  ... ...
  NA.8     NA         NA         NA        NA         NA  NA
  13    650.0 0.00500000         NA 1.0000000 200.000000   1
  NA.9     NA         NA         NA        NA         NA  NA
  .. ...
  NA.12    NA         NA         NA        NA         NA  NA
  18    900.0 0.00500000         NA 1.0000000 200.000000   1
  </code></pre>
  
  <p>I want to make an if-else statement in such a way that, only if all the 'dii' values are >= 20 and 'fsf' is >= 0.8 in the dataframe, the function will print "GOOD", otherwise "You have a problem!". So I tried something like this-</p>
  
  <pre><code>if (dpd$fsf[!is.na(dpd$fsf)] &gt; 0.8 &amp; dpd$dii[!is.na(dpd$dii)] &gt;= 20)
  print("GOOD") else print("You have problem!")
  </code></pre>
  
  <p>The dataframe clearly shows that, row#3 values disobey both conditions, but R only considers the first element as shown below:</p>
  
  <pre><code>[1] "GOOD"
  Warning message:
  In if (dpd$fsf[!is.na(dpd$fsf)] &gt; 0.8 &amp; dpd$dii[!is.na(dpd$dii)] &gt;=  :
    the condition has length &gt; 1 and only the first element will be used
  </code></pre>
  
  <p>How can I improve my conditional statement so that it shows "You have a problem!" Also, is there any way to print the text "GOOD" in a color of my choice?</p>