15

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.

Jen Bohold
  • 1,038
  • 2
  • 10
  • 17

3 Answers3

18

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.

Martin Dinov
  • 8,757
  • 3
  • 29
  • 41
7

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
Aashu
  • 1,247
  • 1
  • 26
  • 41
2

well, let's just function things up

coss <- function(a){
  a=cos(a*pi/180)
  return(a)
}
sinn <- function(a){
  a= sin(a*pi/180)
  return(a)
}
tann <- function(a){
  a= tan(a*pi/180)
  return(a)
}