Hi,
when you do the trunc the mx is not a real integer 1 so you must round up
m<-matrix(data=NA, nrow=10,ncol=10)
i<-1001
mx<-round(trunc(i/1000))
my<-round((i/1000-mx)*1000)
m[mx,my]<-1
m
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]1 NA NA NA NA NA NA NA N
This is similar to FAQ 7.31. my is *printed* as 1, but in fact it is
slightly smaller. Try print(my, digits = 15). Rounding my works.
m<-matrix(nrow=10,ncol=10)
i<-1001
mx<-trunc(i/1000)
my<-round((i/1000-mx)*1000, 0)
m[mx, my]<-1
Thierry
---
2 matches
Mail list logo