A data frame is a matrix-like structure to store data tables. It is a list of vectors of equal length whose columns can be of differing data types
Problem:
Create a Data Frame in R
Solution:
A data frame has the variables of a data set as columns and the observations as rows. Now we can create three vectors as below:
-
A character vector
-
A numeric vector
-
A logical vector
Then, will combine the three vectors into a data frame using the following code:
While working with Data Frames, we may need to work with an extremely large data set. For example, we can use the built-in data frame mtcars.
If the dataset is huge, we may see only a part of the data in the console. we can use the below functions for better understanding.
head(): shows the first observations of a data frame.
tail(): prints out the last observations in your data set.
str(): shows you the structure of your data set
You may also like the below posts:
Thank You For Reading!
0