The sin()
function in R returns the sine of a number in radians.
The illustration below shows the mathematical representation of the sin()
function.
This
sin()
function only works for right-angled triangles.
sin(num)
This function requires a number that represents an angle in radians as a parameter.
To convert degrees to radians, use the following formula.
radians = degrees * ( pi / 180 )
sin()
returns the sine of a number (in radians) that is sent as a parameter. The return value is in the range [-1,1].
#Positive number in radiansa <- sin(2.3);print(paste0("sin(2.3): ", a))#negative number in radiansb <- sin(-2.3);print(paste0("sin(-2.3): ", b))#converting the degrees angle into radians and then applying sin()#degrees = 90c <- sin(90 * (pi / (180)));print(paste0("sin(90 * (pi / (180))): ", c))