[R] cat(), Rgui, and support for carriage return \r...
Martin Sandiford
ms at mcdev.com.au
Sat Mar 18 09:15:25 CET 2006
\r with cat performs a carriage return and line feed in R-GUI.
> for (i in 1:10) { cat("\rFoo",i) }
Foo 1
Foo 2
Foo 3
Foo 4
Foo 5
Foo 6
Foo 7
Foo 8
Foo 9
Foo 10
> _
Performs a carriage return only on the console.
> for (i in 1:10) { cat("\rFoo",i) }
Foo 10> _
Cheers,
Martin
On 18/03/2006, at 6:09 AM, Duncan Murdoch wrote:
> On 3/17/2006 9:44 AM, Jeffrey Racine wrote:
>> Hi, and thanks in advance for your time.
>>
>> Background - I am working on a package and wish to have a routine's
>> progress reported. The routine can take some time, and I would like to
>> inform the user about the routine's progress. I have scoured the
>> archives but to no avail, so would like to solicit input from this
>> list.
>>
>> I am successfully using
>>
>> cat("\rBootstrap replication ", i, " of ", boot.num,)
>> flush.console() # To flush stdout on windows systems
>>
>> which works as expected on *NIX systems and using Rterm under windows.
>> However, under Rgui the carriage return \r is ignored, and I certainly
>> don't want to use the newline escape sequence \n. Under Rgui it
>> appears
>> as
>>
>> Bootstrap replication 1 of 399Bootstrap replication 2 of
>> 399Bootstrap...
>>
>> but I want it to function properly if at all possible.
>>
>> My question is simply whether there is a portable way to implement
>> this
>> so that it works regardless of the R platform the user may be working
>> on?
>>
>> Many thanks for any/all suggestions.
>
> This looks like it would be a useful addition to Rgui to support this.
> The problem is that on Unix or Rterm, it isn't actually R that does
> anything, it's the display that handles the CR with no LF. Rgui uses a
> different mechanism for putting text on the screen, so this would have
> to be implemented specially.
>
> Just out of interest: does the Mac OS X gui handle this like the ascii
> terminals or like Windows Rgui?
>
> Duncan Murdoch
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
More information about the R-help
mailing list