Search code examples
rmathdegreesradians

Convert radians to degree / degree to radians


Are there build-in functions in R for the conversion of radians to degree and degree to radians?

So far I wrote my one own functions:

rad2deg <- function(rad) {(rad * 180) / (pi)}
deg2rad <- function(deg) {(deg * pi) / (180)}

#test:
rad2deg(pi) #180
rad2deg(2*pi) #360
deg2rad(180) #pi

Solution

  • The comment of Pascal was very useful and I found several ones, e.g.

    install.packages("NISTunits", dependencies = TRUE)
    library(NISTunits)
    
    NISTdegTOradian(180)
    NISTradianTOdeg(pi)