Week2 1 Rev
Week2 1 Rev
Basic arithmetic
• Matrix
• List
• Indexing
• Useful functions for organizing data structure
• Data.table
Matrix()
•
Dimension of a Matrix
•
Names of a Matrix
• Use colnames() and rownames()
Use [[ ]]
Use $ to index
Use $ to index
• What if we type mpg < cyl?
✓ It does not work
✓ Outputs an error message → Error: object ‘mpg’ not found
Conditional subset
Add columns
Sorting
• Unique(x)
✓ unique returns a vector or data frame or like x but with duplicate elements/rows removed
✓ Useful when discarding duplicate elements/rows
Homogeneous Heterogeneous
1 dimension Vector List
2 dimensions Matrix Data frame