[R] How to perform a substitution in a loop?

Saji Ren saji.ren at gmail.com
Sat Aug 14 15:18:41 CEST 2010


Hello, Mr Dalgaard:

you're right about the problem.

"Works for me, so there's something you're not telling us.... Possibly
that x is not a vector (a data frame, maybe?)."

the mistake  message is below:
Error in if (track01[i] > 1) track01[i] <- 1 :
  missing value where TRUE/FALSE needed

the track01 above is my data, I've used a rnorm(500) data series instead,
and the code works!!

One thing I do know is that my "track01" data has NaN data.
So I guess the system can not perform the code " if (track01[i] > 1)" when
track01[i]=NaN, or the result is missing value, thus it need a TRUE/FALSE

is there any command to replace the "NaN" value with 1 in an efficient way?

Saji

-----
------------------------------------------------------------------
Saji Ren
from Shanghai China
GoldenHeart Investment Group
------------------------------------------------------------------
-- 
View this message in context: http://r.789695.n4.nabble.com/How-to-perform-a-substitution-in-a-loop-tp2325048p2325193.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list