[R] Remove leading brackets in print?

Marc Schwartz mschwartz at medanalytics.com
Tue Apr 29 19:08:50 CEST 2003


>-----Original Message-----
>From: r-help-bounces at stat.math.ethz.ch 
>[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of R A F
>Sent: Tuesday, April 29, 2003 11:42 AM
>To: r-help at stat.math.ethz.ch
>Cc: raf1729 at hotmail.com
>Subject: [R] Remove leading brackets in print?
>
>
>Hi, I can't seem to get an answer for this by searching 
>through the R-help archives:  How does one remove leading 
>brackets in print?
>
>For example,
>>print( 3 )
>>[1] 3
>
>Would it be possible to get rid of the "[1]"?
>
>Of course the effect is the same without "print", as in,
>>3
>>[1] 3
>but I would only be interested in omitting brackets in 
>printing, if that's possible.
>
>Thanks very much!


Use cat() instead of print().

You will also generally need to append a newline character ("\n") to
the output, as I do below.

Thus, you would use:

> cat(3, "\n")
3 

See ?cat for more information.

HTH,

Marc Schwartz



More information about the R-help mailing list