Overview of R Data Frame
Data frames are a list of vectors with equal length. However, the difference between matrix and data frames is that the data frames accept various types of data. (Character, numeric, etc.). In this topic, we are going to learn about R Data Frame.
Advantages of using data frames
- Distributed collection of data and organized.
- It has better optimizations compared to a relational database.
- Holds a variety of data that is heterogeneous.
Creating a Data Frame in R
We create a data_frame. Below is the example of declaring a data frame.
Data_frame <- data.frame (variable 1,variable 2, variable n…)
In the above example, we haven’t defined the variables. Let’s now see how we assign values to variables and store them in the data frame.
Number <- c(2,3,4)
alpha <- c("x","y","z")
Booleans <- c(TRUE,TRUE,FALSE)
Data_frame <- data.frame(Number,alpha,Booleans)
Number alpha Booleans
1 2 x TRUE
2 3 y TRUE
3 4 z FALSE
Data frames are an important concept in R programming. It is easy yet powerful in creating data sets that can be modified and accessed easily. Just like matrix, the data sets can be accessed through rows and column names with adding and removing data made easy.
This is a guide to R Data Frame. Here we discuss Creating of Data Frame in R with the Structure and Extracting Specific Data from the Data Frame. You may also have a look at the following articles to learn more –