[R] Problem with List() Inside Function

From: Peter Lauren <peterdlauren_at_yahoo.com>
Date: Fri 24 Feb 2006 - 02:32:13 EST


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.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Feb 24 03:19:52 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:43 EST