title: R keep rows where all values are < a threshold
body: <p>I have a data.frame with 19 columns and 2000+ rows. Column 1 is the dependent variable, and columns V1:V17 independent variables. I would like to keep only the rows where the value for EVERY independent variable listed is between 0 and 0.30. However, each row has a varying number of independent variable values. Non-values are filled with NA, but I want to more or less &quot;ignore&quot; the NA values.</p>
  <p>Sample data layout:
  <img src="https://i.stack.imgur.com/PpUTi.jpg" alt="enter image description here" /></p>
  <p>Reproducible sample:</p>
  <pre><code>&gt; dfY &lt;- structure(list(formula_vec1 = structure(c(9L, 3L, 12L, 6L, 11L, 
  5L, 8L, 2L, 7L, 1L, 10L, 4L), .Label = c(&quot;BQbinary10BQBAPA ~ BedrockGrouped&quot;, 
  &quot;BQbinary10BQBAPA ~ FlowCategory2&quot;, &quot;BQbinary10BQBAPA ~ MixedForBinary&quot;, 
  &quot;BQbinary10BQBAPA ~ SurfGeoCode&quot;, &quot;BQbinary10BQBAPA ~ WetBinary&quot;, 
  &quot;BQbinary10BQBAPA ~ WetForBinary&quot;, &quot;BQbinary10TPA ~ BedrockGrouped&quot;, 
  &quot;BQbinary10TPA ~ FlowCategory2&quot;, &quot;BQbinary10TPA ~ MixedForBinary&quot;, 
  &quot;BQbinary10TPA ~ SurfGeoCode&quot;, &quot;BQbinary10TPA ~ WetBinary&quot;, &quot;BQbinary10TPA ~ WetForBinary&quot;
  ), class = &quot;factor&quot;), `(Intercept)` = c(0.273438838044101, 0.706417333314839, 
  0.827323681408328, 0.827323681408328, 0.670245265976437, 1, 0.293077765083469, 
  0.0729824051982314, 1, 0.178457442476982, 0.998548313507269, 
  0.998548313507378), SlopeMIN = c(0.189866676669654, 0.654211112307992, 
  0.544287209863837, 0.544287209863837, 0.994937849813948, 0.999999999999999, 
  0.191210657045005, 0.03858791129829, 0.994491578112418, 0.994856875070902, 
  0.997947006402924, 0.997947006406413), V3 = c(NA, NA, NA, NA, 
  NA, NA, NA, NA, 1, 0.132226649521136, 0.997947006402968, 0.999999999999613
  ), V4 = c(NA, NA, NA, NA, NA, NA, NA, NA, 0.818915198441539, 
  0.0971466407595114, 1, 0.997629408064154), V5 = c(NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, 0.999999999999979, 0.997947006406465
  ), V6 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.999999999999999, 
  0.997947006406414), V7 = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, 0.998510413314225, 0.998586213707042), V8 = c(NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, 0.999999999999999, 0.997947006406413
  ), V9 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
  NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), 
      V10 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_), V11 = c(NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_), V12 = c(NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_), V13 = c(NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_), V14 = c(NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), V15 = c(NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), V16 = c(NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), V17 = c(NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), V18 = c(NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, 
      NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), .Names = c(&quot;formula_vec1&quot;, 
  &quot;(Intercept)&quot;, &quot;SlopeMIN&quot;, &quot;V3&quot;, &quot;V4&quot;, &quot;V5&quot;, &quot;V6&quot;, &quot;V7&quot;, &quot;V8&quot;, 
  &quot;V9&quot;, &quot;V10&quot;, &quot;V11&quot;, &quot;V12&quot;, &quot;V13&quot;, &quot;V14&quot;, &quot;V15&quot;, &quot;V16&quot;, &quot;V17&quot;, 
  &quot;V18&quot;), row.names = 9:20, class = &quot;data.frame&quot;)
  </code></pre>
  <p>Intended output (kept only rows where ALL independent variables were &lt;0.300):
  <img src="https://i.stack.imgur.com/VklCS.jpg" alt="enter image description here" /></p>
  <p>In this small subset only values in V1 are &lt;0.300, but there are other rows in the full data.frame that have multiple variables that meet the criteria.</p>
  <p>I've tried using minimum values to extract the rows that I want, but that only gets the minimum value in each row, where I need ALL values to be &lt;0.300.</p>
  <p>I also tried subsetting the data, but I'm getting hung up with the NA values:</p>
  <blockquote>
  <p>dfOutput &lt;- dfInput[dfInput[,3:19]&gt;0.00000001 | dfInput[,3:19]&lt;0.300, ]</p>
  </blockquote>
  <p>Any ideas on where to go from here would be greatly appreciated.</p>