Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding degree symbol in roxygen2

How to add degree symbol using roxygen2 for R documentation?

°C works in pdf, but it html, it is shown as °C.

Here is the session info.

R version 3.4.0 (2017-04-21)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_India.1252  LC_CTYPE=English_India.1252    LC_MONETARY=English_India.1252
[4] LC_NUMERIC=C                   LC_TIME=English_India.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.4.0 tools_3.4.0   
like image 716
Crops Avatar asked Sep 02 '25 02:09

Crops


1 Answers

To add any non-ASCII characters in R documentation using roxygen2, the encoding must be declared using the tag @encoding.

So when °C is used in the roxygen code, adding the tag @encoding UTF-8 will render it correctly for html as well as pdf.

This can be checked with

path <- "path to Rd file"
tools::checkRd(path)
like image 87
Crops Avatar answered Sep 06 '25 23:09

Crops