title: Need help Subsetting a Data frame in R
body: <p>I have a large dataset (7000+ rows and 42 columns). I want to subset this dataset using specific IDs that each row has. There are 178 IDs I'd like to use and its possible that the IDs occur more than once. I've tried using "filter" from <code>dplyr</code> but I keep getting this error:</p>
  
  <blockquote>
    <p>longer object length is not a multiple of shorter object length"</p>
  </blockquote>
  
  <p>Edit: Sorry I'm still new to most of this, and to this site. </p>
  
  <p>Here is the code I used to try and filter out the specific IDs:</p>
  
  <pre><code>df2 &lt;- filter(df, df$ID==c(2983, 3413,  1266, 3049, 1237,[...],  1002, 1003, 4001)) #the elipsis is there because otherwise code would be too long for this post. 
  </code></pre>
  
  <p>It produces this error:</p>
  
  <pre><code>Warning messages:
  1: In `==.default`(df$ID, c(2983, 3413, 1266, 3049, 1237,  :
    longer object length is not a multiple of shorter object length
  2: In is.na(e1) | is.na(e2) :
    longer object length is not a multiple of shorter object length
  </code></pre>
  
  <p>Edit 2: Thanks for all the help, I was able to fix my issue. I appreciate the feedback and hopefully will be able to be more clear if I have questions for this site in the future.</p>