문제

What is the difference between a vector and a data frame in R? Under what circumstances vectors should be converted to data frames?

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top