title: Pairing a gsub function and text file for corpus cleaning
body: <p>I have a large sample of tweets that I  am trying to clean up before I analyze them. I have the tweets in a dataframe where each cell has the contents of one tweet (e.g. "i love san francisco" and "proud member of the air force"). However, there are some words in each bio that should be combined when I analyze the text in a network visualization. I want to also combine common two-word phrases (e.g. "new york", "san francisco", and "air force"). I have already compiled the list of terms that need to be combined, and have used <code>gsub</code> to combine a few of them with this line of code: </p>
  
  <pre><code>twitterdata_cleaning$bio = gsub('air force','airforce',twitterdata_cleaning$bio)
  </code></pre>
  
  <p>The line of code above turns <code>"proud member of the air force"</code> into <code>"proud member of the airforce"</code>. I have been able to successfully do this with dozens of two-word phrases. </p>
  
  <p>However, I have hundreds of two-word phrases in the bios, and I want to keep a better track of them, so I've moved all of these terms into two columns in an excel file. I would like to find a way to use the above formula on a txt or excel file, that identifies terms in the dataframe that look like those in the first column of the txt file and changes the words to look like those in the second column of the txt file.</p>
  
  <p>For example, I have xlsx and txt files that look like this:</p>
  
  <pre><code>    **column1**               **column2*
     san francisco              sanfrancisco
       new york                   newyork
       las vegas                  lasvegas
       san diego                  sandiego
     new hampshire              newhampshire
        good bye                   goodbye
        air force                  airforce
       video game                 videogame
      high school                  school
      middle school                school
      elementary school            school
  </code></pre>
  
  <p>I would like to use the <code>gsub</code> command in a formula that searches the dataframe for all the terms in <code>column 1</code> and terms them into the terms in <code>column 2</code> using something like this: </p>
  
  <pre><code>twitterdata_df$tweet = gsub('textfile$column1','textfile$columnb',twitterdata_df$tweet)
  </code></pre>
  
  <p>to get something like this in the cells: </p>
  
  <pre><code>i love sanfrancisco
  can not wait to go to newyork
  what happens in lasvegas stays there
  at the beach in sandiego
  can beat the autumn leave in newhampshire
  so done with all the drama goodbye
  proud member of the airforce
  love this videogame so much
  playing at the school tonight 
  so sick of school
  school was the best and i miss it
  </code></pre>
  
  <p>Any help would be very greatly appreciated. </p>