Skip to content
Related Articles

Related Articles

Invisible() Function in R

Improve Article
Save Article
  • Last Updated : 02 Jun, 2022
Improve Article
Save Article

The invisible() function in R Programming Language is used to make the printing statements invisible which means the printing statements will not appear.

Syntax:

invisible(data)

where data is the input data structure/variable.

Example 1:

In this example, we are going to create two vectors and display them both with and without invisible in the R programming language.

R




# create a vector
vec1 = c(1, 2, 3, 4, 5)
  
# create vector2
vec2 = c(56, 5, 5)
  
# display vec2 without invisible
vec2
  
# display vec2 with invisible
invisible(vec2)
  
# display vec1 without invisible
vec1
  
# display vec1 with invisible
invisible(vec1)


Output:

[1] 56  5  5
[1] 1 2 3 4 5

Example 2:

In this example, we are going to create two variables and display both with and without invisible in the R programming language.

R




# create a variable
a = 45
  
# create other
b = 77
  
# display a without invisible
a
  
# display a with invisible
invisible(a)
  
# display b without invisible
b
  
# display b  with invisible
invisible(b)


Output:

[1] 45
[1] 77
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!