[R] c(), or cat(), or paste(), all cause unwanted reordering
Nikos Alexandris
nikos.alexandris at felis.uni-freiburg.de
Tue Apr 6 20:03:51 CEST 2010
On Tue, 2010-04-06 at 19:29 +0200, Nikos Alexandris wrote:
> Jeff Brown wrote:
> > > Wow, you guys are awesome. Thanks!
>
> Nikos Alexandris wrote:
> > Thanks for the "cat()" question Jeff and to all guRus out there for the
> > replies. This is something I was looking for the last hour.
>
> I can't seem to make this run:
>
> I have a function ( Column.of.Matrix.1 , Column.of.Matrix.2 ) which
> gives me an output like:
>
> --%<---
> Divergence: 0.2605
> Jeffries-Matusita: 0.04489
> Bhattacharryya: 0.0227
> Transformed divergence: 0.06406
> --%<---
>
> The custom function uses "cat()" as well to print the above. Now, I
> would like to use this function in a for() loop and print before the
> results a message like "Separability measures between A and B:". I get
> "A" and "B" using "colnames(Matrix.X[i])".
>
> Everything seems to be ok except that the message is printed after the
> results. Although I read all relevant posts in this thread about
> paste(), cat(), c(), I still don't understand why the message is being
> printed in the "end" when I use cat( c( ...)) or paste ( c(...)) or
> other combinations:
>
> --%<---
> cat ( c (
> "Separability measures between:" ,
> "1st sample" , " and " , "2nd sample" , "\n" ,
> function ( Matrix.1 [i] , Matrix.2 [i] ) ,
> collapse = " "
> ) )
> --%<---
>
> Can I *force* the output of the function to be printed in the end?
> Thank you, Nikos
Got it by using a new function which first calls cat(...) and then the
custom.function that gives what I need.
Thanks, Nikos
More information about the R-help
mailing list