Am 13.11.2010 15:48, schrieb Sarah Goslee:
You are assuming that R is using row-major order
for recycling elements, when in fact it is using column-
major order.
It doesn't show up in the first case, because all the
elements of x are identical
Oops. Mental note made.
norm<- function(x, y) {
+ x<- matrix(x, nrow=nrow(y), ncol=ncol(y), byrow=TRUE)
+ sqrt( rowSums( (x-y)^2 ) )
+ }
Ha, thank you!
I am now using this line:
sqrt( rowSums( t( (x-t(y)) )^2 ))
It seems to work, do you see anything wrong with it?
I will have to read up and play around with those "object" thingys you
mentioned -- I am still new to R (and OOP, if that matters).
Thanks again,
Alex
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.