[R] Getting wrong NA values using "for" cmd

VictorDelgado victor.maia at fjp.mg.gov.br
Fri Jul 8 18:20:59 CEST 2011


ty S. Goslee,

It's helpfull to test the condition:

> all.equal(s[4],0.15)
[1] TRUE

instead the previous "FALSE" answer obtained with

>s[4]==0.15
[1] FALSE

but I still need get it to vector r:

Victor Delgado wrote:
> 
> 
>> for (w in 1:length(s)){
>> r[w] <- dados[,3][dados[,2]==s[w]][1]
>> }
> 

I just managed this, writing:

s <- seq(0,1,0.05)
r <- NULL
for (w in 1:length(s)){
r[w] <- dados[,3][dados[,2]==*round(s[w],2)*][1]
}

Now, I get the right answer to r-vector

Thanks for helping!

--
View this message in context: http://r.789695.n4.nabble.com/Getting-wrong-NA-values-using-for-cmd-tp3654335p3654548.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list