title: Iterate over list of data frames and delete columns and rows in every one of them
body: <p>I have several data frames and I want to iterate over them and delete some columns and rows with more than 90% NAs in them. I played around with lapply as well but I cannot get it to work...</p>
  
  <p>My current code is:</p>
  
  <pre><code>data_a_2007 &lt;- read.csv(path)
  data_a_2008 &lt;- read.csv(path)
  datasets_a &lt;- list(data_a_2007, data_a_2008)
  
  for(dataset in datasets_a) {
    columns_to_delete &lt;- NULL
    rows_to_delete &lt;- NULL
  
    # find columns threshold
    threshold_columns &lt;- floor(nrow(dataset)*0.1)
  
    # find columns to delete
    valuecount_columns &lt;- colSums(!is.na(dataset))
    columns_to_delete &lt;- sort(which(valuecount_columns &lt; threshold_columns), decreasing = TRUE)
  
    # find rows threshold
    threshold_rows &lt;- floor(ncol(dataset)*0.1)
  
    # find rows to delete
    valuecount_rows &lt;- rowSums(!is.na(dataset))
    rows_to_delete &lt;- sort(which(valuecount_rows &lt; threshold_rows), decreasing = TRUE)
  
    # delete columns with less than x values  
    for(column_id in columns_to_delete) {
      dataset[column_id] &lt;- NULL
    }
  
    # delete rows with less than x values  
    for (row in rows_to_delete) {
      dataset &lt;- dataset[-row,]
    }
  }
  </code></pre>