This is a pretty simple one. I wanted to show some nicely formatted p-values on a plot by an external library, but it wasn’t possible to pass anything else than a character vector as labels. So I built this function that formats any p-value using unicode characters. Hopefully it’s of use to others as well:

```
pval = function (ps) {
superscript = c('\u{2070}', '\u{00b9}', '\u{00b2}', '\u{00b3}', '\u{2074}',
'\u{2075}', '\u{2076}', '\u{2077}', '\u{2078}', '\u{2079}')
sapply(ps, function(p) {
if (is.na(p)) return("")
if (p < 0 || p > 1) return (sprintf("%.2f", p …
```