R Trigonometric Function


R trigonometric functions include cos(x), sin(x), tan(x), acos(x), asin(x), atan(x), atan2(y,x). Except atan2(y,x), all functions take radians as argument, not degrees.

Sine(π/2):

>sin(pi/2)

[1] 1


Cosine(π):

>cos(pi)

[1] -1


Tangent(π/4):

>tan(pi/3)

[1] 1.732051


Cotangent(π/3):

>1/tan(pi/3)

[1] 0.5773503


Which value has a cosine = -1?

>acos(-1)

[1] 3.141593


Which value has a tangent = 0.5?

>atan(0.5)

[1] 0.4636476

>tan(0.4636476)

[1] 0.5


atan2() take the y and x values as arguments:

>atan2(1,2)

[1] 0.4636476


endmemo.com © 2024  | Terms of Use | Privacy | Home