[Rd] Different behaviour in Linux and Windows (PR#1293)

amurta@ipimar.pt amurta@ipimar.pt
Fri, 1 Feb 2002 16:49:08 +0100 (MET)


Hi

I have written a small function to calculate distances between pairs of
landmarks ('my.dist' bellow). I gave it to a colleague that works with
MSWindows and the function doesn't give the right answer:

R 1.4.1 for Linux: 

> my.dist()
[1]  22 561  

R 1.4.1 for Windows:

> my.dist()
[1]  22 560
Warning message:
Replacement length not a multiple of the elements to replace in
matrix(...)


FYI: S+ 2000 pro. rel.2 for Windows and S+ 6.0 for Linux both give the
same (wrong) answer as R 1.4.1 for Windows.


----------------------------------------------

xy3 <- matrix(round(100*runif(22*68)),22,68)

my.dist <- function(x = xy3){

 landmarks.x <- as.matrix(x[, 1:34])
 landmarks.y <- as.matrix(x[, 35:68])

 x1 <- c()
 x2 <- c()
 y1 <- c()
 y2 <- c()

 for(i in 1:(ncol(landmarks.x) - 1)) {
  x1 <- c(x1, rep(landmarks.x[, i], ncol(landmarks.x) - i))
  x2 <- c(x2, c(landmarks.x[,  - (1:i)]))
  y1 <- c(y1, rep(landmarks.y[, i], ncol(landmarks.x) - i))
  y2 <- c(y2, c(landmarks.y[,  - (1:i)]))
 }

 distan <- sqrt((x1 - x2)^2 + (y1 - y2)^2)
 comb <- prod(ncol(landmarks.x):1)/(2 * prod((ncol(landmarks.x) - 2):1))

 dist.out <- matrix(distan, nrow(x), comb)
 dim(dist.out)
}


-- 
                           Alberto G. Murta                      
           IPIMAR - Institute of Fisheries and Sea Research
            Avenida de Brasilia, 1449-006 Lisboa, Portugal       
Tel:+351 213027062; Fax:+351 213015849; http://www.ipimar.pt/pelagicos/

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._