CLS
CLS

Reputation: 183

List vs Data frame

I imported a 150K row 40 col csv file into R. When I do:

typeof(mydata)

I get:

[1] "list"

However,

is.data.frame(mydata)

returns

TRUE

After spending a lot of time trying to convert mydata to a dataframe (after getting the first result) rather than a list, was I wasting my time?

Why the different results?

Upvotes: 0

Views: 432

Answers (1)

Karsten W.
Karsten W.

Reputation: 18440

You were not wasting your time, since you learned something ;-)

Use class instead of typeof:

class(mydata)

The reason of the result reported by typeof may be that, under the hood, a data.frame is basically a list of columns.

Upvotes: 3

Related Questions