title: How to select cases in R?
body: <p>I'm keen to make the leap from SPSS to R.</p>
  
  <p>A common command used in SPSS is applying filtering. Can somebody please advise on why I am receiving an error message?</p>
  
  <pre><code>2019dataset=read.spss("C:\\SPSS data\\2019dataset.sav")
  
  selected_2019dataset &lt;- 2019dataset[ which(2019dataset$hhweight &gt; 0 &amp; 2019dataset$income~=0 &amp; 2019dataset$age &gt; 16 &amp; 2019dataset$age &lt; 59),]
  </code></pre>
  
  <p>I'm getting an error saying that there is an unexpected '=' </p>
  
  <p>The filter I am trying to replicate in SPSS syntax is:</p>
  
  <pre><code>SELECT IF ((hhweight &gt; 0) AND (income~=0) AND (age &gt; 16 AND age &lt;59)).
  </code></pre>
  
  <p>I've been following the example here:</p>
  
  <p><a href="https://www.statmethods.net/management/subset.html" rel="nofollow noreferrer">https://www.statmethods.net/management/subset.html</a></p>
  
  <p>Grateful for any suggestions.</p>
  
  <p>Thanks.</p>