The tan()
function in R returns the tangent of a number in radians.
The following illustration shows the mathematical representation of the tan()
function.
This
tan()
function only works for right-angled triangles.
tan(num)
This function requires a number that represents an angle in radians as a parameter.
To convert degrees to radians, use the following formula.
radians = degrees * ( pi / 180.0 )
tan()
returns the tangent of a number (in radians) that is sent as a parameter.
#Positive number in radiansa <- tan(2.3);print(paste0("tan(2.3): ", a))#negative number in radiansb <- tan(-2.3);print(paste0("tan(-2.3): ", b))#converting the degrees angle into radians and then applying tan()#degrees = 45c <- tan(45 * (pi / (180)));print(paste0("tan(45 * (pi / (180))): ", c))