title: Index of character position in string -- str_locate() and gregexpr() not working
body: <p>I'm trying to find the string position for a "(" parenthesis character in order to make a new variable, but my usual methods aren't working. Both <code>str_locate()</code> and <code>grepexpr()</code> return an error about invalid regex syntax: <code>invalid regular expression '(', reason 'Missing ')''</code></p>
  
  <p>This could have been a solution: <code>which(strsplit(df$var, "")[[1]] == "("</code>, but it doesn't work for making new variables. </p>
  
  <p>Here are some reproducible examples:</p>
  
  <pre><code>txt &lt;- "some text (in parentheses)"
  df &lt;- structure(list(number = 1:3, txt = c("text (in parentheses)", 
  "some text (in parentheses)", "some more text (in parentheses)"
  )), .Names = c("number", "txt"), row.names = c(NA, 3L), class = "data.frame")
  df
  
  ## find position of 'm' -- these all work
  stringr::str_locate(txt, "m")[[1]]
  gregexpr("m", txt)[[1]][1]
  
  ## find position of '(' -- now they don't work
  stringr::str_locate(txt, "(")[[1]]
  gregexpr("(", txt)[[1]][1]
  
  ## find position of '(' -- this works for a character string...
  which(strsplit(txt, "")[[1]] == "(")
  
  ## ...but not for making a new variable
  df$newVar &lt;- which(strsplit(df$txt, "")[[1]] == "(")
  df #wrong
  </code></pre>