R: Add "th", "rd" and "nd" to dates
<p>I have some dates, which I can extract the day of the month from: </p>

<pre><code>trimws(format(seq.Date(
  from = as.Date("2016-01-01"),
  to = as.Date("2016-10-01"), by = "day"), "%e"))
</code></pre>

<p>I would like to format the dates with suffixes "th", "rd" or "nd" as appropriate. So, "1st", "2nd", "3rd", etc. Is there an easy way to accomplish this, or will I have to enumerate the rules?  </p>

<hr>

<p>I can implement this as a brute force lookup: </p>

<pre><code>df_dates = data_frame(
  day = seq.int(31),
  suffix = c(
    "st",
    "nd",
    "rd",
    rep("th", 17),
    "st",
    "nd",
    "rd",
    rep("th", 7),
    "st"
  )
)
</code></pre>

<p>but a more elegant solution would be welcome. </p>