What is the difference between a vector and a data frame in R? Under what circumstances vectors should be converted to data frames?
+7
A:
A vector has 1 dimension while a data frame has 2. I can't think of a good reason to convert a single vector into a data frame. That question generally arises when you have multiple vectors.
A better question is what is the difference between a data frame and a matrix: a data frame can have different data types for each column, while a matrix is all one data type. Behind the scenes, a data frame is really a list with equal length vectors at each index.
Shane
2010-02-17 11:48:21
I was just going to ask you the difference between matrices and data frames. Thanks for the explanation.
Mehper C. Palavuzlar
2010-02-17 11:53:38
+2
A:
Another good point to note is that when running code, operations on matrixes are (most of the time) much faster then on data frames.
Tal
Tal Galili
2010-02-17 13:16:32