text: user9449: I have a data frame of raw read counts, genes in rows and samples in columns
  > dput(head(oc))
  structure(list(sample1 = c(13L, 0L, 1L, 42L, 15L, 1137L), sample2 = c(21L, 
  2L, 20L, 51L, 5L, 203L), sample3 = c(25L, 2L, 6L, 71L, 36L, 1346L
  ), sample4 = c(59L, 3L, 8L, 58L, 42L, 3428L), sample5 = c(19L, 
  4L, 8L, 52L, 1L, 201L)), row.names = c("WASH7P", "MIR6859-1", 
  "CICP27", "WASH9P", "MTND1P23", "MTND2P28"), class = "data.frame")
  > 
  
  > head(oc)
            sample1 sample2 sample3 sample4 sample5
  WASH7P         13      21      25      59      19
  MIR6859-1       0       2       2       3       4
  CICP27          1      20       6       8       8
  WASH9P         42      51      71      58      52
  MTND1P23       15       5      36      42       1
  MTND2P28     1137     203    1346    3428     201
  > 
  
  I just want to keep genes with at least 10 reads in each sample, I mean even if a gene has less than 10 reads in one sample and the rest of four samples have 10 reads, this gene should be removed. For instance here the second, third and fifth rows should be removed
  I tied this but all I obtained zero
  > df=t(oc)
  > cutoff <- 10
  > 
  > # encode the data based on the cutoff
  > df[df >= cutoff] <- 1
  > df[df < cutoff] <- 0
  > View(df)
  > rowSums(df)
  sample1 sample2 sample3 sample4 sample5 
        0       0       0       0       0 
  > 
  
  > apply(df >= 5, 1, sum)
  sample1 sample2 sample3 sample4 sample5 
        0       0       0       0       0 
  > apply(df >= 1, 1, sum)
  sample1 sample2 sample3 sample4 sample5 
        0       0       0       0       0 
  > 
  
  Any suggestion please?
  
  user3541: apply(my_df >= 10, 1, sum) would give you that how many of the samples satisfy your criteria. Basically you apply() the function sum() to the rows (denoted as 1). The sum() does the trick that @Devon Ryan suggested above.
  
original_text: 9449: <p>I have a data frame of raw read counts, genes in rows and samples in columns</p>
  <pre><code>&gt; dput(head(oc))
  structure(list(sample1 = c(13L, 0L, 1L, 42L, 15L, 1137L), sample2 = c(21L, 
  2L, 20L, 51L, 5L, 203L), sample3 = c(25L, 2L, 6L, 71L, 36L, 1346L
  ), sample4 = c(59L, 3L, 8L, 58L, 42L, 3428L), sample5 = c(19L, 
  4L, 8L, 52L, 1L, 201L)), row.names = c(&quot;WASH7P&quot;, &quot;MIR6859-1&quot;, 
  &quot;CICP27&quot;, &quot;WASH9P&quot;, &quot;MTND1P23&quot;, &quot;MTND2P28&quot;), class = &quot;data.frame&quot;)
  &gt; 
  
  &gt; head(oc)
            sample1 sample2 sample3 sample4 sample5
  WASH7P         13      21      25      59      19
  MIR6859-1       0       2       2       3       4
  CICP27          1      20       6       8       8
  WASH9P         42      51      71      58      52
  MTND1P23       15       5      36      42       1
  MTND2P28     1137     203    1346    3428     201
  &gt; 
  </code></pre>
  <p>I just want to keep genes with at least 10 reads in each sample, I mean even if a gene has less than 10 reads in one sample and the rest of four samples have 10 reads, this gene should be removed. For instance here the second, third and fifth rows should be removed</p>
  <p>I tied this but all I obtained zero</p>
  <pre><code>&gt; df=t(oc)
  &gt; cutoff &lt;- 10
  &gt; 
  &gt; # encode the data based on the cutoff
  &gt; df[df &gt;= cutoff] &lt;- 1
  &gt; df[df &lt; cutoff] &lt;- 0
  &gt; View(df)
  &gt; rowSums(df)
  sample1 sample2 sample3 sample4 sample5 
        0       0       0       0       0 
  &gt; 
  
  &gt; apply(df &gt;= 5, 1, sum)
  sample1 sample2 sample3 sample4 sample5 
        0       0       0       0       0 
  &gt; apply(df &gt;= 1, 1, sum)
  sample1 sample2 sample3 sample4 sample5 
        0       0       0       0       0 
  &gt; 
  </code></pre>
  <p>Any suggestion please?</p>
   3541: <p><code>apply(my_df &gt;= 10, 1, sum)</code> would give you that how many of the samples satisfy your criteria. Basically you <code>apply()</code> the function <code>sum()</code> to the rows (denoted as <code>1</code>). The <code>sum()</code> does the trick that @Devon Ryan suggested above.</p>
  