[R] Is there a faster way to do it?

Marcio Resende mresendeufv at yahoo.com.br
Wed Oct 28 17:55:56 CET 2009


#Mdarts is a matrix 2343x788
#frequencia is a vector 2343x1
# 9 in Mdarts[fri,frj] stands for my missing values which i want to replace
by the value in the vector frequencia


Mdarts<-t(matrix(scan("C:/GWS/CNB/dartg.txt"),ncol=nindT,nrow=nm, byrow=T))
frequencia <- matrix(scan("C:/GWS/CNB/freq.txt"),ncol=1)
for (fri in 1:nindT){
for (frj in 1:nm){
Mdarts[fri,frj] <- if (Mdarts[fri,frj] == 9) frequencia[frj] else
Mdarts[fri,frj]
Mdarts[fri,frj] <- Mdarts[fri,frj]/1-(frequencia[frj]^2)
}
}

Is there a faster way to it?
Maybe using any apply function?
Thanks in advance
-- 
View this message in context: http://www.nabble.com/Is-there-a-faster-way-to-do-it--tp26098223p26098223.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list