Here we are explaining how to write an R program to create an empty data frame. Here we are using a built-in function data.frame() for creating it. A data frame is used for storing data tables which has a list of vectors with equal length. The data frames are created by function data.frame(), which has tightly coupled collections of variables.
Below are the steps used in the R program to create an empty data frame. In this R program, we directly give the values to the built-in function. And print the function result. Here we used the variable Df is used as a data frame. The data frame consists of different data types which are integer, Doubles, Characters, Logical, Factors, Strings As Factors.
Df = data.frame(Ints=integer(),
Doubles=double(),
Characters=character(),
Logicals=logical(),
Factors=factor(),
stringsAsFactors=FALSE)
print("Structure of the empty dataframe:")
## [1] "Structure of the empty dataframe:"
print(str(Df))
## 'data.frame': 0 obs. of 5 variables:
## $ Ints : int
## $ Doubles : num
## $ Characters: chr
## $ Logicals : logi
## $ Factors : Factor w/ 0 levels:
## NULL