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 8156593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:59:56+00:00 2026-06-06T16:59:56+00:00

Having a bit of a mental block. I am sure I found a function

  • 0

Having a bit of a mental block. I am sure I found a function to print iteration numbers in a for loop that was not print and not cat, but gave the same output as cat below.

> for(i in 10^(1:5))  print(i)
[1] 10
[1] 100
[1] 1000
[1] 10000
[1] 1e+05
> for(i in 10^(1:5))  cat(i, "\n")
10 
100 
1000 
10000 
1e+05 

I cannot see any reference to it in the R help files for print and cat. Tried googling for it, but not getting anywhere.

  • 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-06T16:59:58+00:00Added an answer on June 6, 2026 at 4:59 pm

    It’s easy enough to define a wrapper function around cat:

    catn <- function(x, append="\n"){cat(x); cat(append)}
    

    Use it:

    for(i in 10^(1:5))  catn(i)
    10
    100
    1000
    10000
    1e+05
    

    Or you can use message (which has the added benefit that in some code editors, e.g. Eclipse, the messages appear in a different colour):

    for(i in 10^(1:5))  message(i)
    10
    100
    1000
    10000
    1e+05
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a bit of trouble with a a function that the mongodb c
Im having a bit of a mental block on this one. I got booking
Okay, I'm having a bit of a mental block today/this week, so I'm probably
Having a bit of trouble wrapping my head around this one. I'm sure the
I know I've come across this problem before, but I'm having a bit of
I'm having bit complicated object model that forms a triangle. There is User entity
Having a bit of trouble. I need to find all of the countries that
Having a bit of a brain fart right now, but I'm needing help converting
having a bit of a prob with this, though I'm sure it's simple! I
Im having a bit of trouble with a function of mine .. .it doesnt

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.