Create Dataframe in R Programming Language
To create an R data frame use data.frame() function and then pass each of the vectors you have created as arguments to the function.
R
# R program to create dataframe # creating a data frame friend.data <- data.frame ( friend_id = c (1:5), friend_name = c ( "Sachin" , "Sourav" , "Dravid" , "Sehwag" , "Dhoni" ), stringsAsFactors = FALSE ) # print the data frame print (friend.data) |
Output:
friend_id friend_name
1 1 Sachin
2 2 Sourav
3 3 Dravid
4 4 Sehwag
5 5 Dhoni
R – Data Frames
R Programming Language is an open-source programming language that is widely used as a statistical software and data analysis tool. Data Frames in R Language are generic data objects of R that are used to store tabular data.
Data frames can also be interpreted as matrices where each column of a matrix can be of different data types. R DataFrame is made up of three principal components, the data, rows, and columns.