Hi, 

I am trying to do some calculations turning DMS data to decimal degrees using 
the formula (D+(M/60)+(S/3600)), some of the D's involve -ve numbers, the 
easiest way to do the calculation is to use absolute numbers then use the 
'sign' 
function in R to change the answer back to the correct -ve or +ve,

for example, if;
D<--69
M<-8
S<-10
then
decimal<-D+(M/60)+(S/3600)
-69+(8/60)+(10/3600)   = this would equal -68.86389  (which is wrong, it should 
be -69.13611,  so i used the following function)

decimal<-(abs(D)+(M/60)+(S/3600))
decimal.degs<-sign(D)*decimal
decimal.degs
-69.13611

because ((69+(8/60)+(10/3600)=69.13611) and then the -sign is put back in. 

This works fine untill D=0
because then 'sign' does not give 0 a +ve sign it takes it as 0 and multiplies 
decimal by 0 to give 0. 
example
D<-0
decimal<-D+(M/60)+(S/3600)
decimal.degs<-sign(D)*decimal
decimal.degs
0

Is there anyway to get around this??????????
and make D=0 a positive and not a 0 with sign or another function??????

Any help is appreciated
Thank you
sadz 

ps please email me if you need more info



      
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to