0% found this document useful (0 votes)
4 views1 page

Data Frame

A data frame is a matrix-like structure that allows for different data types in its columns, such as characters and numbers. It includes named columns, which can be accessed by their names, and is the standard format for data in R. The document provides examples of creating a data frame and accessing its columns.

Uploaded by

ravinder singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Data Frame

A data frame is a matrix-like structure that allows for different data types in its columns, such as characters and numbers. It includes named columns, which can be accessed by their names, and is the standard format for data in R. The document provides examples of creating a data frame and accessing its columns.

Uploaded by

ravinder singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

A data frame is basically a matrix, except it allows for diferent columns to have diferent classes.

Ie,
you can have both character and numerical columns in a data frame. Furthermore, columns in a data
frame have a name, and there is a special way to access these columns by name. The data frame is the
standard format used for data; when you are more interested in performing matrix operatons, it is
more memory efcient to store such things in a matrix rather than a data frame. Let’s learn by
example:
myFrame <- [Link]( x = 1:5, y = letters[1:5] )
myFrame
Note that R already stores all the lowercase leters in a vector called letters,
Similarly, uppercase leters can be accessed from a vector called LETTERS. Why does
letters[1:5] return the leters a, b, c, d, e?

Note that we’ve created a data frame with two columns: one named x, flled with numbers 1 to 5, and
a second column named y, flled with leters a to e.
Suppose we want to access the column of numbers. We could then write,
myFrame$x
and this will pull out the vector in myFrame that has the name x. If you want to check the names
assigned to a given data frame you can type
names( myFrame )
and this will output all the column names contained in that data frame.

You might also like