Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:47:09+00:00 2026-06-02T11:47:09+00:00

I like to do use this in my scripts: cat(Saving…) do_something_slow() cat(\rSaved\n) The problem

  • 0

I like to do use this in my scripts:

cat("Saving...")
do_something_slow()
cat("\rSaved\n")

The problem is that the carriage return is applied without erasing the rest of the line, so I get this:

Savedg...

To fix it I can do:

cat("\rSaved\033[K\n")

but it’s kind of ugly. Is there a simpler way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:47:10+00:00Added an answer on June 2, 2026 at 11:47 am

    I like to use message() instead of cat() for generating messages. For example:

    cat("Saving..."); cat("\rSaved\n")

    returns:

    Savdg...
    

    While:

    message("Saving..."); message("\rSaved\n")

    returns:

    Saving...
    Saved
    

    Edit:

    Inspired by @gauden answer, another function could be:

    replaceMessage <- function(x, width = 80)
    {
        message("\r", rep(" ", times = width - length(x)), "\r", appendLF = F)
        message(x, appendLF = F)
    }
    

    And then:

    replaceMessage("Saving..."); Sys.sleep(1); replaceMessage("Saved\n")
    

    Note:

    While replaceMessage() behaves as expected in Linux and Rterm on Windows, it behaves strangely in my Rgui (2.15.0, Windows x64). Specifically, Saving... is never displayed, and after Saved is displayed, the cursor is moved width spaces (in the example, 80 spaces) to the right. I am not sure why.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cookie that I use on my app. It looks like this:
I'd like to use this method to create user-friendly URL. Because my site is
So, I would like to use this magic find function in my CakePHP 2.0
SQL Server provides the type [rowguid]. I like to use this as unique primary
I usually use like this $ find -name testname.c ./dir1/dir2/testname.c $ vi ./dir1/dir2/testname.c it's
Is it possible to use something like this wrapper with fluent configuration? http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-repository-classes-simple/ If
I am doing pass-by-reference like this: use strict; use warnings; sub repl { local
The examples I see are suggesting the use like this: $response = new Response();
So I've got this audit table, looks like this: USE [DatabaseName] GO /****** Object:
I am using two update panel..in nested way.. can i use like this and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.