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
How To Convert Radians to Degrees? The conversion of measure of an angle from radians to degrees can be done using the following formula: Angle in Radians × 180°/π = Angle in Degrees. For example, consider an angle π/9 rad. Now, using the radians to degrees formula, we have π/9 rad × 180°/π = (Angle in Degrees).
The value of 180 degrees in radians is π. Because 2π = 360 degrees. When we divide both sides by 2, we get π = 180 degrees.
So one radian = 180/ PI degrees and one degree = PI /180 radians. Therefore to convert a certain number of degrees in to radians, multiply the number of degrees by PI /180 (for example, 90º = 90 × PI /180 radians = PI /2). To convert a certain number of radians into degrees, multiply the number of radians by 180/ PI .
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)
You can use the units
package for this.
library(units)
pi_rad <- as_units(pi, "radians")
pi_deg <- set_units(pi_rad, "degrees")
set_units(pi_deg, "radians")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With