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

  • Home
  • SEARCH
  • 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 8293829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:58:08+00:00 2026-06-08T13:58:08+00:00

R help explains invisible() as a function that returns a temporarily invisible copy of

  • 0

R help explains invisible() as “a function that returns a temporarily invisible copy of an object”. I have difficulty understanding what invisible() is used for. Would you be able to explain what invisible() does and when this function can be useful?

I’ve seen that invisible() is almost always used in method functions for the print(). Here is one example:

### My Method function:
print.myPrint <- function(x, ...){
  print(unlist(x[1:2]))
  invisible(x)
}

x = list(v1 = c(1:5), v2 = c(-1:-5) )
class(x) = "myPrint"
print(x)

I was thinking that without invisible(x), I wouldn’t be able to do assignment like:

a = print(x)

But it’s actually not the case.
So, I’d like to know what invisible() does, where it can be useful, and finally what it’s role is in the method print function above?

Thank you very much for your help.

  • 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-08T13:58:10+00:00Added an answer on June 8, 2026 at 1:58 pm

    From ?invisible:

    Details:

     This function can be useful when it is desired to have functions
     return values which can be assigned, but which do not print when
     they are not assigned.
    

    So you can assign the result, but it will not be printed if not assigned. It’s often used in place of return. Your print.myPrint method only prints because you explicitly call print. The call to invisible(x) at the end of your function simply returns a copy of x.

    If you didn’t use invisible, x would also be printed if not assigned. For example:

    R> print.myPrint <- function(x, ...){
    +   print(unlist(x[1:2]))
    +   return(x)
    + }
    R> print(x)
    v11 v12 v13 v14 v15 v21 v22 v23 v24 v25 
      1   2   3   4   5  -1  -2  -3  -4  -5 
    v11 v12 v13 v14 v15 v21 v22 v23 v24 v25 
      1   2   3   4   5  -1  -2  -3  -4  -5 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent hours trying to find a resource that explains the process of
To help further my understanding of WSGI I'm looking for a diagram which explains
I need help, my layouts and containers are lingering on after I have used
I have a query with regards to pointers, can someone help explain the following
Help me translate following block of the Haskell code. The run function produces text
Is there any documentation available that explains the internals of JQuery and JQuery UI?
Your help would be very much appreciated. I do not understand why the following
I am currently working though this tutorial , that explains how to add Core
Note: You may be able to help me with this just by directing me
Can someone point me to a web-cast or tutorial/video that explains this new namespace

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.