data.frame()

The data.frame method in R is used to create a data frame object into the R working space. It is an in-built method in R Programming Language. 

R




#creating the data frame by defining the x and y coordinates respectively
x_pos <- 1:10
#defining the y axis 
y_pos = 5:14
#creating the data frame
data_frame = data.frame(x_pos, y_pos )
print("Data Frame")
print(data_frame)


Output

[1] "Data Frame"
   x_pos y_pos
1      1     5
2      2     6
3      3     7
4      4     8
5      5     9
6      6    10
7      7    11
8      8    12
9      9    13
10    10    14

Difference Between as.data.frame() and data.frame() in R

R Programming Language contains a large number of data structures, data frames being very crucial in it. It is used to organize the data in a well-arranged tabular manner. Data frames can both be created from scratch as well as other data objects can be converted to data frames easily using large inbuilt R methods. 

Similar Reads

as.data.frame()

The as.data.frame() method in R is used to check if a particular R object is a data frame or not.  If not, it is used to convert the R objects into the data frame object. The objects taken as arguments may be vectors, lists or matrices. It is an in-built method in R. The as.data.frame method has the following syntax :...

data.frame()

...

Difference Between as.data.frame() and data.frame() in R

The data.frame method in R is used to create a data frame object into the R working space. It is an in-built method in R Programming Language....

Contact Us