Data frames and matrices

Verimli R Kodu Yazma

Colin Gillespie

Jumping Rivers & Newcastle University

The data frame

  • Key data structure in R
    • Copied in other languages
      • Python: pandas data frame
      • If you can't beat them, join them!
Verimli R Kodu Yazma

Data frames

  • Tabular structure: rows and colums
    • read.csv()and friends returns a data frame
      • Columns
    • Data must be the same type
      • Rows
    • Different type
Storage

Selection

Verimli R Kodu Yazma

Matrices

  • It's a rectangular data structure
    • You can perform usual subsetting and extracting operations
    • BUT - every element must be the same data type
Storage

Selection

Verimli R Kodu Yazma

R club

The third rule of R club: Use a matrix whenever appropriate.

Verimli R Kodu Yazma

Let's practice!

Verimli R Kodu Yazma

Preparing Video For Download...