Re: [R] cat and positioning of the output

From: Michael H. Prager <Mike.Prager_at_noaa.gov>
Date: Fri 30 Jun 2006 - 06:56:22 EST

It works on Windows (rgui.exe) with this change:

 for ( i in 1:10 ) { cat("Number",i,"\r"); flush.console(); Sys.sleep(1) }; cat("\n")

MHP on 6/29/2006 4:33 PM Dan Gunter said the following:

> =?ANSI_X3.4-1968?Q?J=3Frn_Schulz?= wrote:
>   

>> Hello R users!
>>
>> I like to use cat in a loop. I know, loops are not the best way in R ... but
>> my question: It is possible to overwrite the expression "Reading row: i" in
>> each iteration of the loop (print out in the below loop on the screen) or
>> more particulary to overwrite the counter "i".
>>
>> for(i in 1:header$M){
>> cat("Reading row: ", i)
>> SparseIndex[[i]] <- readBin( con, integer(), n=MIndexNumber[i], size=4 )
>> SparseSignal[[i]] <- readBin( con, numeric(), n=MIndexNumber[i], size=4 )
>> }
>>
>> Many thanks
>> J?rn Schulz.
>>
>>
> On a UNIX terminal, adding '\r' will cause the cursor to go back to the 
> beginning of the same line. I can't speak for Windows.
>
> e.g.
>
> for ( i in 1:10 ) { cat("Number",i,"\r"); Sys.sleep(1) }; cat("\n")
>
> -Dan
>
>   

-- 
Michael Prager, Ph.D.
Southeast Fisheries Science Center
NOAA Center for Coastal Fisheries and Habitat Research
Beaufort, North Carolina  28516
** Opinions expressed are personal, not official.  No
** official endorsement of any product is made or implied.

______________________________________________
R-help@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
Received on Fri Jun 30 07:00:33 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 30 Jun 2006 - 08:15:10 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.