[R] Changing sign on absolute numbers 0 problems

Ben Bolker bbolker at gmail.com
Wed Oct 20 21:25:47 CEST 2010


Sadz A <sadz_a1000 <at> yahoo.co.uk> writes:

> 
> 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
> 

  decimal.degs <- ifelse(D==0,1,sign(D))*decimal

 work?



More information about the R-help mailing list