[Rd] Unexpected behavior with cat

2010-11-08 Thread Russell Pierce
I am experiencing unexpected behavior with the command cat under
Window GUI builds of R version 2.12.0 (it does not seem to be an issue
in Rterm).  For example if I issue the command cat(70,"\r") I get back
text that looks like Asian characters.  If I highlight and copy that
text, it is the text I would regularly expect, e.g. the number 70 and
the prompt line.  Highlighting the text changes what is shown on the
screen, but the screen never displays the number 70.  This error is
not idiosyncratic to 70 but happens with a fairly wide range of
numbers.  Notably no error like this occurs when I use \n.  I use \r
for large simulation runs when I don't want my progress to spam the
display.

e.g.
for (i in 1:1000) {cat(i,"\r");flush.console();Sys.sleep(.100)}

sessionInfo() where I first saw the problem:
R version 2.12.0 (2010-10-15) on Windows Vista
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

Also experienced here:
R version 2.12.0 (2010-10-15) on Windows XP
R version 2.12.0 Patched (2010-11-04 r53530) on Windows Vista
R version 2.13.0 Under development (unstable) (2010-11-04 r53530) on
Windows Vista

But not here:
Not under R version 2.10.1 (2009-12-14) on Windows XP

If this is expected behavior would you please kindly explain it to me?
 I am not a member of this list, so please address replies both to my
email address and (if appropriate) the list.

Best,

Russell Pierce

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Unexpected behavior with \r in Rgui 2.12.0

2010-11-25 Thread Russell Pierce
Prof. Ripley & Joris,

I concur with Joris, the behavior persists in R version 2.12.0 Patched
(2010-11-24 r53655) and  under Windows XP.  The current development build
for Windows did not have an RGui at the time I wrote this.

I did not realize that the functionality of "\r" to return to
the beginning of the line in Windows was undocumented/unsupported.  ?Quotes
lists \r as carriage return without any warning that it is unsupported in
RGui, perhaps a notice should be put in?

Since "\r" is not supported, I would like to express a desire that it at
least do something predictable.  Certainly, it seems doubtful that
these "strange characters" (with the copying characteristics described) is
what a user expects.  If "\r" is not usable under RGui perhaps it would be
better to ignore it entirely than to parse it and return the odd output that
I am seeing?

In the RGui for Windows prior to this version "\r" returned to
the beginning of the line without deleting the already written content.
 Thus cat(70,"\r") and cat("\r",70) only differed in terms of where the
cursor was left.

I started using "\r" because I had seen it in the code for txtProgressBar.
 The help for txtProgressBar does note that it "uses \r to return to the
left margin – the interpretation of carriage return is up to the terminal or
console in which *R* is running". For Jorris' reference, in a windows
environment there are several methods to produce keep track of progress:
tcltk::tkProgressBar, utils::txtProgressBar , and utils::winProgressBar.
 None of them are as "user friendly" as cat and "\r" because you have to
create the progress bar, increment it, then destroy it.  If you want to
output debugging information as well as increment a counter you need to
tweak the title attribute as you go.

Best,

Russell S. Pierce

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel