title: Selecting only integers from a vector
body: <p>I have a question regarding selecting specific values from a vector in R. More specifically, I want to select all integer values from a given variable in my dataset (I want to use these to subset my data). Here is an example:</p>
  
  <pre><code>x &lt;- seq(0,10,1/3)
  </code></pre>
  
  <p>Now I want to select all the observations in the vector x with integer numbers. My first idea was to use the <code>is.integer</code>command, but this does not work. I found a workaround solution using the following:</p>
  
  <pre><code>&gt; x==as.integer(x)
   [1]  TRUE FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE
  FALSE TRUE FALSE FALSE  TRUE
  [17]  FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE 
  FALSE  TRUE FALSE FALSE  TRUE
  </code></pre>
  
  <p>Now I can simply type</p>
  
  <pre><code>&gt; which(x==as.integer(x))
   [1]  1  4  7 10 13 16 19 22 25 28 31
  </code></pre>
  
  <p>and I get the expected result (and I can use this vector for subsetting my dataset). But isn't there a more direct way to select integer values?</p>