[R] ifelse

pking
Sat, 24 Oct 2009 17:22:46 -0000

When I run this code from an R-script:
       ddd = 360 + round ( atan2(-u,-v) / d2r )
       print(class(ddd))
       print(ddd)
       ifelse ( ddd>360, ddd-360, ddd )
       print(ddd)

I get this output:
[1] "numeric"
[1] 461 213 238 249 251
[1] 461 213 238 249 251

Why does ifelse not change the 461 to 101?

I recreated the vector ddd and ran the same ifelse
code and it did work as expected.

> ddd <- c(461, 213, 238, 249, 251)
> print(class(ddd))
[1] "numeric"

> print(ddd)
[1] 461 213 238 249 251

> ifelse ( ddd>360, ddd-360, ddd )
> print(ddd)
[1] 101 213 238 249 251

What am I missing?

Patrick King


--
View this message in context:
http://www.nabble.com/ifelse-tp26041165p26041165.html
Sent from the R help mailing list archive at Nabble.com.