[R] Incorrect Dimension

Marcio Resende mresendeufv at yahoo.com.br
Fri Sep 18 04:50:04 CEST 2009


I am new in R and i am having trouble here. I´ve already searched in the list
but hasn´t helped
When i run this script above i get the message "Error in gen[j, i] :
incorrect number of dimensions". However gen is 1000x200 (ind x loc) and so
is g

could anybody help me

for (i in 1 : loc) {      #loc=200
for (j in 1 : ind) {      #ind=1000

g1 <= function ( gen ) matrix ( if (gen[j, i] == 0) al1 [i, 1] + al1 [i, 1]
else if (gen [j, i] == 1) al1 [i, 1]       +  al2 [i, 1] else if  (gen [j,
i] == 2) al2 [i, 1] + al2 [i, 1] else 999, ncol = loc, nrow = ind)


g2 <= function ( gen ) sample (b1, 1, re = T)  #b1 is 1x3 and came from a
vector 1000X1 (e.g b1 <- c(x     [1000,1]...)

xx <= if (runif (1) >= (1 - r2)) g1 else g2

g [j, i] <= xx (gen [j, i])    #g was already generated as an 0 matrix
(1000x200) and i would like to replace ##by those functios

}
}

Thank you very much
-- 
View this message in context: http://www.nabble.com/Incorrect-Dimension-tp25502336p25502336.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list