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.

**Syntax**

`sin(x)`

**Parameters**

The sin() function accepts **x** as a parameter.

**Example**

```
a1 <- -120
a2 <- 90
sin(a1)
sin(a2)
```

**Output**

```
[1] -0.5806112
[1] 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)
```

**Output**

```
[1] 1
[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)
```

**Output**

`[1] 1.000000e+00 -1.000000e+00 1.224647e-16 8.660254e-01`

That is it for the sin() function in the R language.

**See also**

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.