列表中列的数据类型 - R [英] Data Type of Columns in a List - R

查看:530
本文介绍了列表中列的数据类型 - R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提取R中列表中不同列的数据类型。



我使用以下函数:

  my.data.types<  -  t(sapply(贷款数据,
函数(x)c(typeof(x))存储。模式(x),模式(x))))

然而,我得到的数据类型与我的数据不一样。



例如,loan.purpose存储字符串,但我得到的结果如下:

  loan.purposeintegerintegernumeric

如何获取列的数据类型?



谢谢,



Diego

解决方案

正如cbeleites所指出的,这个问题的答案是

  sapply(loanData,class)


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

解决方案

As pointed out by cbeleites the answer to this question is

sapply (loansData, class)

这篇关于列表中列的数据类型 - R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆