What is atan() in R?

The atan()also called the arc tangent function function in R returns the inverse tangent of a number. More specifically, it returns the inverse tangent of a number in radians.

Figure 1 below shows the mathematical representation of the atan() function.

Figure 1: Mathematical representation of inverse tangent function

Figure 2 shows the visual representation of the atan() function.

Figure 2: Visual representation of inverse tangent function

Methodology

To convert radians to degrees, use:


degrees = radians * ( 180.0 / pi )

Syntax


atan(num)

Parameter

This function requires a number as a parameter.

Return value

atan() will return the inverse tangent of a number (radians) sent as a parameter. The return values lie in the interval [-pi/2,pi/2] in radians.

Code

#Positive number in radians
a <- atan(0.5);
print(paste0("atan(0.5): ", a, " radians"))
#negative number in radians
b <- atan(-0.5);
print(paste0("atan(-0.5): ", b, " radians"))
#applying atan() and then converting the result in radians to degrees
#radians = 1.0
c <- atan(1) * (180.0 / pi);
print(paste0("tan(1): ", c, " degrees"))

Free Resources