All trigonometric functions that are available in R are the sine, cosine, and tangent method and their inverse methods.
cos() in R
The cos() is an inbuilt mathematical R function that computes the cosine value of numeric value data. To calculate the cosine of a value in R, use the cos() function.
The cos() function takes x as an argument is either numeric or complex vectors.
This code doesn’t give you the correct result, however, because R always works with angles in radians, not in degrees. Pay attention to the fact; if you forget, the resulting bugs may bite you hard in the, er, leg.
The correct way to calculate the cosine of an angle of 30 degrees, then uses the following code.
cos(30 * pi / 180)
Cos value of pi in R
The pi in R is an inbuilt constant. Let’s find the cos() value of the pi constant.
Let’s pass the -pi.
Applying cos() function to a Vector
To create a Vector in R, use the c() function. Add three elements of a vector using the pi constant.
rv <- c(pi, pi / 4, pi / 3) cos(rv)
 -1.0000000 0.7071068 0.5000000
That is it for cos() function in R language.