My solution when I run into mysteries like this
is to put
browser()
in the function just before or after the line of
interest.
The magnitude and direction of my stupidity usually
become clear quickly.
Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S
User")
Peter Lauren wrote:
I have a function declared thus.
FirstEigenvectorBoundary.Training <-
function(InputFileName='C:/Samples2/PT_Amp.txt',
Header=TRUE, Colour="red")
Inside the function, I have the following call
out<-list(x=Eigenvectors[2:(NumMetricsSelected+1),1],
y=-0.8, z=NumMetricsSelected);
NumMetricsSelected has the value 2 and Eigenvectors
has the following form
[,1] [,2] [,3]
[1,] 0.6404630 -0.2153989 0.7371638
[2,] -0.6081319 0.4439621 0.6580830
[3,] 0.4690231 0.8697706 -0.1533503
When I do it manually at the console, I get the
correct result. I.e.
$x
[1] -0.6081319 0.4690231
$y
[1] -0.8
$z
[1] 2
However, when I call the function like this
Training<-FirstEigenvectorBoundary.Training()
$x
[1] 0.658083
$y
[1] -0.8
$z
[1] 2
That is, the $x element has only one value (instead
2) and it is from the wrong part of the matrix.
Can anyone see what I am doing wrong?
Thanks very much,
Peter.