Open In App

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

Last Updated : 19 Jun, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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: Python3 1==
# 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)
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: Python3 1==
# 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)
Output:
[1] FALSE
  A B C
A 1 4 7
B 2 5 8
C 3 6 9
[1] TRUE

Next Article

Similar Reads