0% found this document useful (0 votes)
62 views

Data Frames Data Frames: Row - Names Read - Table Read - CSV Data - Matrix

Data frames are a special type of list used to store tabular data in R. They represent data as columns that can each contain different data types, unlike matrices which require all elements to be the same type. Data frames have rows identified by row names and are typically created by reading in files with functions like read.table() or read.csv(). They can be converted to matrices which require uniform element types.

Uploaded by

RustEd
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Data Frames Data Frames: Row - Names Read - Table Read - CSV Data - Matrix

Data frames are a special type of list used to store tabular data in R. They represent data as columns that can each contain different data types, unlike matrices which require all elements to be the same type. Data frames have rows identified by row names and are typically created by reading in files with functions like read.table() or read.csv(). They can be converted to matrices which require uniform element types.

Uploaded by

RustEd
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Frames

Data frames are used to store tabular data


They are represented as a special type of list where every element of the list has to have the
same length
Each element of the list can be thought of as a column and the length of each element of the list
is the number of rows
Unlike matrices, data frames can store different classes of objects in each column (just like lists);
matrices must have every element be the same class
Data frames also have a special attribute called row.names
Data frames are usually created by calling read.table() or read.csv()
Can be converted to a matrix by calling data.matrix()

22/27

Data Frames
> x <- data.frame(foo = 1:4, bar = c(T, T, F, F))
> x
foo
bar
1
1 TRUE
2
2 TRUE
3
3 FALSE
4
4 FALSE
> nrow(x)
[1] 4
> ncol(x)
[1] 2

23/27

You might also like