title: replace tabs and line break R
body: <p>I'm cleaning a large text file to read into R. Almost each line is separated by tabs, but a few long quotations also have line breaks. I am using the tabs to separate the document into a dataframe with a speaker column and a comments column, and these line breaks are ruining my formatting because R thinks that each line is a new speaker but then says the speaker is <em>NA</em> when it doesn't find a tab. Here's a sample below of what I have: </p>
  
  <pre><code>Interviewer: How are you?
  
  Subject: I'm just incredibly frustrated. &lt;br/&gt;
  *NA* Really, R is frustrating me. &lt;br/&gt;
  *NA* But maybe someone has a solution for me?
  
  Interviewer: Fortunately, I have an answer for you.
  </code></pre>
  
  <p>And here's what I want:</p>
  
  <pre><code>Interviewer: How are you?
  
  Subject: I'm just incredibly frustrated. Really, R is frustrating me. But maybe someone has a solution for me?
  
  Interviewer: Fortunately, I have an answer for you.
  </code></pre>
  
  <p>I'm reading the document in this way:</p>
  
  <pre><code>atas &lt;- stri_read_lines("ATAS2.txt") %&gt;% str_replace_all("\t", "TABS_TO_BE_DELETED")
  </code></pre>
  
  <p>(I have that random string because R keeps erasing the tabs when I make the text document a data frame, just FYI).</p>
  
  <p>Now, to remove the line breaks, I've tried:</p>
  
  <pre><code>atas2 &lt;- gsub("\r?\n|\r", " ", atas) 
  </code></pre>
  
  <p>And</p>
  
  <pre><code>atas2 &lt;- str_replace_all(atas, "\n" , " ")
  </code></pre>
  
  <p>I also can't just remove all special characters or formatting to solve this. If I DO have to remove all non-alphanumeric characters, I need to preserve the <strong>tabs</strong> (at least long enough to put in some obscure string in their place that I can later split on), <strong>?</strong>, <strong>.</strong>, <strong>[]</strong>, <strong>()</strong>, and <strong>:</strong>.</p>
  
  <p>I want to either have it ignore those line breaks or somehow merge the rows together. The only caution with just telling it to merge with unmatched rows is I have some lines by themselves without any speaker that will need to be in the speaker column with no attribution, such as (but not limited to):</p>
  
  <pre><code>(Laughter)
  
  Interview 41
  
  [Inaudible cross-talk]
  </code></pre>
  
  <p>I appreciate any help that you can offer!</p>