title: User defined R function to drop rows with 3 (or more) NAs in different data frames?
body: <p>Is there a way to create a user defined function so I don't have to keep typing the same lines of code over and over?</p>
  <p>I have one data frame containing the raw data and I have separate data frames for each measure that I'm using. The lines of code I am writing over and over again is this:</p>
  <pre><code>df1Final &lt;- df1[rowSums(is.na(df1)) &lt; 3, ]
  
  df2Final &lt;- df2[rowSums(is.na(df2)) &lt; 3, ]
  
  df3Final &lt;- df3[rowSums(is.na(df3)) &lt; 3, ]
  </code></pre>
  <p>I am using separate data frames and not the raw data frame because I only want to remove people if they have 3 or more missing cells in a measure.</p>
  <p>I would also like to rename the df1, df2, df3, etc. to include &quot;Final&quot; at the end. I've tried this user defined function below but it doesn't work like I want it to (and it doesn't allow me to have &quot;Final&quot; at the end of the data frame name.</p>
  <pre><code>missingData &lt;- function(df) {
    df &lt;- df[rowSums(is.na(df)) &lt; 3, ]
  
  }
  </code></pre>
  <p>Thank you!</p>
  <p>Edit: I have tried searching for a solution already but have yet to find one!</p>