Open In App

Invisible() Function in R

Last Updated : 02 Jun, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

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

Next Article
Article Tags :

Similar Reads