Radian measure in sin in R?

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.

Answers


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

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.


Need Your Help

Force Git submodules to always stay current

git git-submodules

I love git submodules. Also, I hate git submodules. What I love about them is how it enables to you to cleanly compartmentalize dependencies etc. I get the point of having them point to a specific

Groovy equivalent of Scala views

scala groovy

I am trying to convert this Scala code to Groovy: