I want to calculate the following in R:
sin(52.517°)
and this should be equal to 0.79353. But when I code
sin(52.517)
I get
0.777119
So how can I get the 0.79353. I am not good in math, but I know something is not working with degrees and the radian measure here in R.
What is sin() in R? 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 in the R console: Angles are in radians, not degrees (i.e., a right angle is π/2). So by default, the trigonometric functions take radians as input and not degrees.
From the help page on sin which you can read by typing in ?sin in the R console: Angles are in radians, not degrees (i.e., a right angle is π/2). So by default, the trigonometric functions take radians as input and not degrees.
Imagine a circle and a central angle in it. If the length of an arc that this angle cuts off the circle equals to its radius, then, by definition, this angle's measure is 1 radian. If an angle is twice as big, the arc it cuts off the circle will be twice as long and the measure of this angle will be 2 radians.
In case of radians, one should understand the concept of circles and related terms along with their meaning and formulas. In this article, what is the radian measure of an angle, how to find the measure of an angle in radians and measurement of different angles in radians are explained.
Thus 2 π radians is equal to 360 degrees, meaning that one radian is equal to 180/ π ≈ 57.29577 95130 82320 876 degrees. , and by using a circle of radius 1. Since radian is the measure of an angle that subtends an arc of a length equal to the radius of the circle, . This can be further simplified to .
From the help page on sin
which you can read by typing in ?sin
in the R console:
Angles are in radians, not degrees (i.e., a right angle is π/2).
So by default, the trigonometric functions take radians as input and not degrees. To get the sin(52.517)
you need to convert those degrees to a radian measure first:
52.517 degrees = 52.517 * (pi/180) = sin(52.517*(pi/180)) = 0.916...
If you do:
sin(52.517*(pi/180))
you get the wanted 0.7935339.
it works
1 degree =0.0174532925 radians
sin(52.517*0.0174532925)
[1] 0.7935339
EDIT
refered from here
degrees.to.radians<-function(degrees=45,minutes=30)
{
if(!is.numeric(minutes)) stop("Please enter a numeric value for minutes!\n")
if(!is.numeric(degrees)) stop("Please enter a numeric value for degrees!\n")
decimal<-minutes/60
c.num<-degrees+decimal
radians<-c.num*pi/180
radians
}
sin(degrees.to.radians(52.517,0))
[1] 0.7935339
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With