How to Load Data Frames in R?

Data Frames in R Language are generic data objects of R which are used to store the tabular data. Data frames can also be interpreted as matrices where each column of a matrix can be of the different data types. DataFrame is made up of three principal components, the data, rows, and columns.

Extract data from a data frame means that to access its rows or columns. One can extract a specific column from a data frame using its column name.


# R program to extract
# data from the data frame
# creating a data frame <- data.frame(
    friend_id = c(1:5),
    friend_name = c("Sachin", "Sourav",
                    "Dravid", "Sehwag",
    stringsAsFactors = FALSE
# Extracting friend_name column
result <- data.frame($friend_name)

1                  Sachin
2                  Sourav
3                  Dravid
4                  Sehwag
5                   Dhoni