R Data Frames

📊 R Data Frames

Data Frames in R are the most important and commonly used data structure for data analysis.

They store data in a tabular (table-like) format with rows and columns.


 1. What is a Data Frame?

  • Two-dimensional structure

  • Each column can have different data types

  • Similar to a table in Excel or SQL

  • Columns are vectors of equal length


 2. Creating a Data Frame


 


 3. Structure of Data Frame


 

Shows:

  • Column names

  • Data types

  • Sample values


 4. Accessing Data Frame Data

a) By Column Name


 


b) By Row & Column Index


 


c) Using $ Operator


 


5. Add New Column


 


 6. Add New Row


 


 7. Remove Column / Row

Remove column


 

Remove row


 


 8. Filtering Data (Very Important)


 


 9. Summary & Statistics


 


 10. Check Dimensions



 


 11. Convert to Data Frame


 


 Data Frame vs Matrix

FeatureData FrameMatrix
Data typesDifferentSame
UsageData analysisMath
Column namesYesOptional

 Best Practices ✔

  • Use meaningful column names

  • Avoid row names if possible

  • Keep data clean and consistent


📌 Summary

  • Data frames are table-like structures

  • Most used structure in R

  • Columns can have different data types

  • Powerful for filtering & analysis

You may also like...