Open In App

Check if the Object is a Data Frame in R Programming – is.data.frame() Function

is.data.frame() function in R Language is used to return TRUE if the specified data type is a data frame else return FALSE. R data.frame is a powerful data type, especially when processing table (.csv). It can store the data as row and columns according to the table.

Syntax: is.data.frame(x)



Parameters:
x: specified data.frame

Example 1:






# R program to illustrate
# is.data.frame function
  
# Specifying "Biochemical oxygen demand"
# data set
x <- BOD
  
# Calling is.data.frame() function
is.data.frame(x)

Output:

[1] TRUE

Example 2:




# R program to illustrate
# is.data.frame function
  
# Calling is.data.frame() function 
# over different data types
is.data.frame(4)
is.data.frame("34")
is.data.frame("a")
is.data.frame(2.7)

Output:

[1] FALSE
[1] FALSE
[1] FALSE
[1] FALSE
Article Tags :