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.

Example:

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

Output:

   friend.data.friend_name
1                  Sachin
2                  Sourav
3                  Dravid
4                  Sehwag
5                   Dhoni