title: How to filter out columns that have negative values and save the rest of the columns in a new data frame
body: <p>I would like to filter out from a data frame all variables that have negative values. I used this line of code (below) to get the names of the columns but how can I save the positive columns with their data as a new data frame</p>
  
  <pre><code>dat &lt;- read.table(text = " value jobs  chairs    tables     lamps  vases
                                  -1     0        0        0         7  9
                                   2     0        0        1         1  6 
                                  -3     0        1        0         3  5 
                                   4     0        1        1         7  8 
                                  -5     1        0        0         5  4
                                  -6     1        0        1         1  3 
                                   7     1        1        0         0  7
                                   8     1        1        1         6  6
                                   9     0        0        0         8  9  ", header = TRUE) 
  
  names(dat)[sapply(dat, function(x) min(x))&gt;=0]
  [1] "value"  "jobs"   "chairs" "tables" "lamps"  "vases"
  </code></pre>