Check if an Object is a Table in R Programming – is.table() Function

is.table() function in R Language is used to check if an object is a table.

Syntax: is.table(x)

Parameters:
x: Object to be checked

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R Program to check
# if an object is a table
  
# Creating a vector
vec = c(2, 4, 3, 1, 2, 3, 2, 1, 4, 2
  
# calling is.table() Function
is.table(vec)
  
# Converting to table
x <- as.table(vec)
x
  
# Calling is.table() again
is.table(x)

chevron_right


Output:

[1] FALSE
A B C D E F G H I J 
2 4 3 1 2 3 2 1 4 2 
[1] TRUE

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R Program to convert 
# an object to a table
  
# Creating a matrix
mat = matrix(c(1:9), 3, 3)
  
# Calling is.table() function
is.table(mat)
  
# Converting to table
x <- as.table(mat)
x
  
# Calling is.table() function again
is.table(x)

chevron_right


Output:

[1] FALSE
  A B C
A 1 4 7
B 2 5 8
C 3 6 9
[1] TRUE
My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.