Explain the difference between a matrix and a data frame in R. When would you choose one over the other?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
Overview: Asks how an R matrix differs from a data frame and when each one is the right container. It tests knowledge of R storage and type coercion, matrix algebra versus mixed-type tabular data, and the conversion pitfalls that show up with as.matrix and apply.