In mathematics, the sine is a trigonometric function of an angle. For example, the sine of an acute angle is defined in the context of a right triangle. For the specified angle, it is the ratio of the length of the side opposite that angle to the length of the longest side of the triangle.
sin in R
The sin() is a built-in mathematical R function that computes the sine value of the input numeric value. The sin() method accepts a numeric value as an argument and returns the sine value.
To calculate the sine of a value in R programming, use the sin() function.
The sin() function accepts x as a parameter.
a1 <- -120 a2 <- 90 sin(a1) sin(a2)
 -0.5806112  0.8939967
Passing pi to the sin() function
The pi is an inbuilt R constant. Let’s pass the pi to the sin() function and see the output.
a1 <- pi / 2 a2 <- -pi / 3 sin(a1) sin(a2)
 1  -0.8660254
Applying sin() function to a Vector
To define a vector in R, use the c() function. Pass this newly created vector to the sin() function.
rv <- c(pi / 2, - pi / 2, pi, pi / 3) sin(rv)
 1.000000e+00 -1.000000e+00 1.224647e-16 8.660254e-01
That is it for the sin() function in the R language.