[R] Difference between console output of cat and print

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Tue Apr 18 00:01:30 CEST 2017

Please stop posting html email per the Posting Guide. You are only going to reduce the chance of successfully communicating your questions to experienced users on this list.

Re cat vs print: the purpose of print is to show values much as they are entered in source code, so quotes and escaped characters such as "\n" are shown. Cat is intended to provide a way to send characters straight to the console so the effects of special characters can be visible (i.e. getting text on the next line when a "\n" occurs in a string). Thus the element numbering is not relevant there.
Sent from my phone. Please excuse my brevity.

On April 17, 2017 12:18:36 AM PDT, Data MagicPro <datamagicpro2017 at gmail.com> wrote:
>Since both *cat * as well as * print * create a character vector for
>outputing on the screen. Still both give different results as apparant
>below. My query is why so ?
>> cat(10)
>> print(10)
>[1] 10
>Why is the [1] of index number missing in case of *cat *?
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list