title: R function is returning "Character (0)" instead of Cardinal Direction
body: <p>I am attempting to convert wind direction (values 0-360) into a cardinal direction (ie NW). My code is below:</p>
  
  <pre><code>DegToDer &lt;- function(degree) {
    value &lt;- as.integer((degree / 45)+ .5)
    direction &lt;- c("N","NE","E","SE","S","SW","W","NW")
    return(direction[((value+1) %% 8)])}
  </code></pre>
  
  <p>When I run it on my column I get the following error:</p>
  
  <blockquote>
    <p>replacement has 346 rows, data has 365</p>
  </blockquote>
  
  <p>I've tested it out with a few values and found out that every thing that should return the value "NE" is only returning "character (0)"</p>
  
  <pre><code>&gt; DegToDer(293)
  character(0)
  &gt; DegToDer(292)
  [1] "W"
  &gt; DegToDer(360)
  [1] "N"
  </code></pre>
  
  <p>Any and all assistance on this issue is greatly appreciated!</p>