A data frame in R represents the data displayed in a table format. Like a table with columns and rows, a data frame can contain different data types inside it.
In R, we use the data.frame()
function to create a data frame.
# creating a data frame My_Data_Frame <- data.frame ( Height = c("Tall", "Average", "short"), Body_structure = c("Meso", "Endo", "Ecto"), Age = c(35, 30, 45) ) # Print the data frame My_Data_Frame
data.frame()
function to create a data frame variable My_Data_frame
. This data frame contains three columns.We use the summary()
function to summarize the data from a data frame.
summary(data frame)
This function takes the data frame object as its single parameter value.
This function returns a summary (statistical inference) of the data frame.
# creating a data frame My_Data_frame <- data.frame ( Height = c("Tall", "Average", "Short", "Tall"), Body_structure = c("Meso", "Endo", "Ecto", "Endo"), Age = c(35, 30, 45, 25) ) # Print the data frame My_Data_frame # Summarizing the data summary(My_Data_frame)
This is similar to the previous example, except we use the summary()
function to summarize the data frame My_Data_frame
. This can be observed from the output of the code.
RELATED TAGS
CONTRIBUTOR
View all Courses