[R] print(), paste()

Dirk Eddelbuettel edd at debian.org
Tue Sep 24 14:04:21 CEST 2002


On Tue, Sep 24, 2002 at 11:34:05PM +1200, Ko-Kang Kevin Wang wrote:
>   print(answer) # Print the answer
>   # Now, find the best fitted n degree polynomial
>   print(paste("The best fit is with", which.min(answer) - 1,
>               "-degree polynomial"))
[...]
> In other words I'd like my output to look like:
>   [1] 2 1 0 4 5
>   "The best fit is with 2-degree polynomial"    

You want cat() instead of print(), and sprintf() is one way to get finer
control over how things are printed:

> answer <- c(2,1,0,4,5)
> print(answer); cat(sprintf("The best fit is with %.0f-degree polynomial\n",
                              which.min(answer)-1))
[1] 2 1 0 4 5
The best fit is with 2-degree polynomial


Dirk

-- 
Good judgement comes from experience; experience comes from bad judgement. 
							    -- Fred Brooks
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list