Convert Radians to Degree & Back in R Programming (2 Examples)

In this tutorial you’ll learn how to transform radian to degree and vice versa in R programming.

Setting up the Examples

install.packages("units")                               # Install & load units package
library("units")
my_radians <- as_units(c(3.43, 7.15, 6.22), "radians")  # Create example radians
my_radians
# Units: [rad]
# [1] 3.43 7.15 6.22

Example 1: Transforming Radians to Degree Using set_units() Function of units Package

my_degree <- set_units(my_radians, "degrees")           # Converting radians to degree
my_degree
# Units: [°]
# [1] 196.5245 409.6648 356.3797

Example 2: Transforming Degree to Radians Using set_units() Function of units Package

my_radians_b <- set_units(my_degree, "radians")         # Converting degree to radians
my_radians_b
# Units: [rad]
# [1] 3.43 7.15 6.22

Leave a Reply

Your email address will not be published.

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top