Diego
Diego

Reputation: 864

Data Type of Columns in a List - R

I want to "extract" the data types of the different columns in a list in R.

I'm using the following function:

my.data.types <- t(sapply(loansData,
             function(x) c(typeof(x), storage.mode(x), mode(x))))

However, the data types I'm getting are not the same as the data I have.

For example, loan.purpose stores strings but the result I get is the following:

loan.purpose                   "integer" "integer" "numeric"

How can I get the data types of my columns?

Thanks,

Diego

Upvotes: 3

Views: 7163

Answers (1)

Diego
Diego

Reputation: 864

As pointed out by cbeleites the answer to this question is

sapply (loansData, class)

Upvotes: 4

Related Questions