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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.