The arccos function is an inverse of the cos() function. It returns the angle whose cosine is a given number. Means: The angle whose cosine is 0.866 is 30 degrees. Use arccos or acos function when you know the cosine of an angle and want to know the actual angle.
acos in R
The acos() is an inbuilt mathematical R function that returns the radian arccosine of number data. To calculate the arc cosine of the specified radian value, use the acos() function in R programming. The acos() function also returns the value in radians.
The acos() function takes radian as an argument.
The acos() function returns the arc cosine value of radian. It is a Numeric value, array, or vector.
Passing a pi to the acos() function
The pi is an inbuilt constant in R programming, and its value is 3.141593.
Let’s find the pi constant’s acos() value.
 NaN Warning message: In acos(pi) : NaNs produced
You can see that it returns NaN(not a number) in the output.
Let’s see another example of pi.
acos(pi / 4)
Applying an acos() function to Vector
To create a Vector in R, use the c() function. But, first, let’s create a vector and pass that to the acos() function.
data <- c(-1, -0.850250, -0.507107, -0.4, 0, 0.4, 0.507107, 0.850250, 1) acos(data)
 3.1415927 2.5872564 2.1026212 1.9823132 1.5707963 1.1592795 1.0389715  0.5543363 0.0000000
That is it for this tutorial.
Krunal Lathiya is an Information Technology Engineer by education and web developer by profession. He has worked with many back-end platforms, including Node.js, PHP, and Python. In addition, Krunal has excellent knowledge of Data Science and Machine Learning, and he is an expert in R Language. Krunal has written many programming blogs, which showcases his vast expertise in this field.