[R] Beginner troubles.
Gaute B Strokkenes
gs234-r-help at srcf.ucam.org
Thu Aug 26 20:36:09 CEST 2004
I'm new to R. Having read through a good chunk of "An Introduction to
R" I'm trying to use R to do some relatively straight-forward
(mathematically speaking) stuff.
I have a file which contains the coordinates of a set of points in
R^3, with one point per line (i.e. three real numbers). The aim is to
read that file in and produce the set of all the distances between all
possible different pairs of points in that file. So I try:
> a <- read.table("FL_BR14.xyz")
> dim(a)
[1] 329 3
> A <- function(i) a[i, ]
> A(1)
V1 V2 V3
1 -1558.364 16.97055 1004.381
> d <- function(x, y) sqrt(sum((x - y) * (x - y)))
> outer(1:length(a[, 1]), 1:length(a[, 1]), function(u,
v) d(A(u), A(v)))
Error in outer(1:length(a[, 1]), 1:length(a[, 1]), function(u, v) d(A(u), :
dim<- : dims [product 108241] do not match the length of object [1]
This last error has me stumped. Could anyone give me a pointer in the
right direction?
--
Gaute Strokkenes http://www.srcf.ucam.org/~gs234/
I'm CONTROLLED by the CIA!! EVERYONE is controlled by the CIA!!
More information about the R-help
mailing list