Typeof (data.frame) shows a "list" in R

Can someone clarify why typeof (data.frame) shows a list in R? In contrast, the class gives the expected type. For example, demonstrate that using the built-in mtcars data.frame.

> typeof(mtcars)
[1] "list"
> class(mtcars)
[1] "data.frame"

Any tips on how to use typeof versus class?

+4
source share
1 answer

data.frame and data.table are a collection (list) of elements (vectors, if you want), each element is the same length (i.e. each column is an element in the list, internally up to R anyway). This is why, unlike matrices, columns can have different classes.

Greetings.

+3
source

Source: https://habr.com/ru/post/1682591/


All Articles