Re: [R] Problem with List() Inside Function

From: Peter Lauren <peterdlauren_at_yahoo.com>
Date: Sat 25 Feb 2006 - 23:36:15 EST


Dear Dr. Burns,

Many thanks for your reply. I figured out what the problem was. I had neglected to put the line out;
at the end of the function. Once I did that, everything was fine.

Thanks again,
Peter.

> 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@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.
> >
> >
> >>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
> >
> >
> >
> >
> >
>
>



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 Sat Feb 25 23:51:48 2006

This archive was generated by hypermail 2.1.8 : Sun 26 Feb 2006 - 03:08:47 EST