[R] print(), paste()

Carlos Ortega carlos.ortega at minorplanet.com
Wed Sep 25 09:14:49 CEST 2002


Hello,

For the second question, use the option "sep" within the paste command.

paste("The best fit is with ", which.min(answer) - 1,"-degree polynomial",
sep="")

Regards,
Carlos.

-----Mensaje original-----
De: owner-r-help at stat.math.ethz.ch
[mailto:owner-r-help at stat.math.ethz.ch]En nombre de Ko-Kang Kevin Wang
Enviado el: martes, 24 de septiembre de 2002 13:34
Para: R Help
Asunto: [R] print(), paste()


Hi,

Suppose I have the following lines at the end of a function:
  answer <- c(2, 1, 0, 4, 5) # In fact, answer will be generate in my
                             # function
  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"))
this will return:
  [1] 2 1 0 4 5
  [1] "The best fit is with 2 -degree polynomial"

Two questions:

1) How can I supress the [1] in the second line in the output?

2) The second line has ...with 2 -degree... , how can I make it display
...with 2-degree...?

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"


Cheers,

Kevin

----------------------------------------------------------------------------
--
Ko-Kang Kevin Wang
Postgraduate PGDipSci Student
Department of Statistics
University of Auckland
New Zealand
Homepage: http://www.stat.auckland.ac.nz/~kwan022


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


_____
The information in this email is confidential and it may not be
disclosed or used by anyone other than the addressee. If you are not the
intended recipient, any disclosure, copying, distribution or any action taken or
omitted is prohibited and may be unlawful.
Minorplanet cannot accept responsibility for the accuracy or completeness of
this email as it has been transmitted over a public network. If you suspect
that the email may have been amended, please call the sender.


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