title: How to replace / rename rows given some pattern in string?
body: <p>I would like to convert some links corresponding to unique userID:</p>
  
  <pre><code>    df&lt;- data.frame(
  
        employeeId = c(1,2,3,4,5,6),
        linkToEmployee = c("http://intranet.homepageEmploye.com/herSalary",
                         "http://intranet.homepageEmploye.org/herSalary/Details",
                         "http://local.com/qa/for",
                         "here the homepage is missing",
                         "http://local.org/",
                         "here the homepage is missing"))
  
  
           employeeId                       linkToEmployee
  
      1          1         http://intranet.homepageEmploye.com/herSalary
      2          2 http://intranet.homepageEmploye.org/herSalary/Details
      3          3                               http://local.com/qa/for
      4          4                          here the homepage is missing
      5          5                                     http://local.org/
      6          6                          here the homepage is missing
  </code></pre>
  
  <p>Now I would like convert those links to that form:</p>
  
  <pre><code>    desired&lt;- data.frame(
  
          employeeId = c(1,2,3,4,5,6),
          linkToEmployee = c("intranet.com",
                             "intranet.org",
                             "local.com",
                             "here",
                             "local.org",
                             "here"))
  
  
              employeeId linkToEmployee
  
        1          1   intranet.com
        2          2   intranet.org
        3          3      local.com
        4          4           here
        5          5      local.org
        6          6           here
  </code></pre>
  
  <p>I have tried to use <code>gsub</code> for the case of intranet but that doesnt seem to work as expected.</p>
  
  <pre><code>    df$linkToEmployee &lt;- gsub("http://intranet.homepageEmploye.com/", "intranet.com.", df$linkToEmployee)
  </code></pre>
  
  <p>However that doesnt work as expected</p>