title: Conditional subset of data from list base on date R
body: <p>I have several .csv files containing hourly data. Each file represents data from a point in space. The start and end date is different in each file.</p>
  
  <p>The data can be read into R using:</p>
  
  <pre><code>lstf1&lt;- list.files(pattern=".csv")
  
  lst2&lt;- lapply(lstf1,function(x) read.csv(x,header = TRUE,stringsAsFactors=FALSE,sep = ",",fill=TRUE, dec = ".",quote = "\""))
  
  head(lst2[[800]])
               datetime precip code
  1 2003-12-30 00:00:00     NA    M
  2 2003-12-30 01:00:00     NA    M
  3 2003-12-30 02:00:00     NA    M
  4 2003-12-30 03:00:00     NA    M
  5 2003-12-30 04:00:00     NA    M
  6 2003-12-30 05:00:00     NA    M
  </code></pre>
  
  <p><code>datetime</code> is <code>YYYY-MM-DD-HH-MM-SS</code>, <code>precip</code> is the data value, <code>code</code>can be ignored.</p>
  
  <p>For each dataframe (df) in <code>lst2</code> I want to select data for the period <code>2015-04-01</code> to <code>2015-11-30</code> based on the following conditions:</p>
  
  <p>1) If <code>precip</code> in a <code>df</code> contains all <code>NAs</code>within this period, delete it (do not select)
  2) If <code>precip</code> is not all <code>NAs</code> select it.</p>
  
  <p>The desired output (<code>lst3</code>) contains the sub-setted data for the period <code>2015-04-01</code> to <code>2015-11-30</code>. </p>
  
  <p>All dataframes in <code>lst3</code> should have equal length with <code>days</code> and <code>hours</code>without <code>precip</code>denoted as <code>NA</code></p>
  
  <p>The I can write the files in <code>lst3</code> to my directory using something like:</p>
  
  <pre><code>sapply(names(lst2),function (x)  write.csv(lst3[[x]],file = paste0(names(lst2[x]), ".csv"),row.names = FALSE)) 
  </code></pre>
  
  <p><a href="https://www.dropbox.com/s/5lya8tiwxkax4c0/L112FN0M.262.csv?dl=0" rel="nofollow">The link to a sample file can be found here (~200 KB)</a></p>