title: How to determine if string ends with line break (EOL) in R?
body: <p>Is there any elegant way in R to determine of string ends with line break character ('\n' or '\r').</p>
  
  <p>I was only able to come up with, which seems to work correctly, but I was wondering if there is a more elegant way.</p>
  
  <pre><code>d&gt; s &lt;- "string\n"
  d&gt; substr(s, nchar(s), nchar(s)) == '\n'
  [1] TRUE
  </code></pre>
  
  <p>UPD:
  There might be line breaks in the somewhere in a string. I need to know if it ends with line break.</p>
  
  <pre><code>s &lt;- "string\nstring"
  </code></pre>