title: dplyr filter on a vector rather than a dataframe in R
body: <p>This seems like a simple question, but I have not come across a clean solution for it yet. I have a vector in R and I want to remove certain elements from the vector, however I want to avoid the vector[vector != "thiselement"] notation for a variety of reasons. In particular, here is what I am trying to do:</p>
  
  <pre><code># this doesnt work
  all_states = gsub(" ", "-", tolower(state.name)) %&gt;% filter("alaska")
  
  # this doesnt work either
  all_states = gsub(" ", "-", tolower(state.name)) %&gt;% filter(!= "alaska")
  
  # this does work but i want to avoid this approach to filtering
  all_states = gsub(" ", "-", tolower(state.name))
  all_states = all_states[all_states != "alaska"]
  </code></pre>
  
  <p>can this be done in a simple manner? Thanks in advance for the help!</p>
  
  <p>EDIT - the reason I'm struggling with this is because I'm only finding things online regarding filtering based on a column of a dataframe, for example:</p>
  
  <pre><code>my_df %&gt;% filter(col != "alaska")
  </code></pre>
  
  <p>however I'm working with a vector not a dataframe here</p>