[R] Problem with List() Inside Function
    Peter Lauren 
    peterdlauren at yahoo.com
       
    Thu Feb 23 16:32:13 CET 2006
    
    
  
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.
> out
$x
[1] -0.6081319  0.4690231
$y
[1] -0.8
$z
[1] 2
However, when I call the function like this
> Training<-FirstEigenvectorBoundary.Training()
I get
>Training
$x
[1] 0.658083
$y
[1] -0.8
$z
[1] 2
That is, the $x element has only one value (instead of
2) and it is from the wrong part of the matrix.
Can anyone see what I am doing wrong?
Thanks very much,
Peter.
    
    
More information about the R-help
mailing list