环境中有什么类别的对象? (R) [英] What class of objects are in the environment ? (R)

查看:96
本文介绍了环境中有什么类别的对象? (R)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在我的环境中有什么类型的物品。

I wish to know what type of objects I've got in my environment.

我可以显示谁是这样的:

I can show who is there like this:

ls()

运行像

sapply(ls(), class)

会(显然)不能告诉我们对象的类型(类)(函数,数值,因子等)

Would (obviously) not tell us what type (class) of objects we are having (function, numeric, factor and so on...)

使用

ls.str()

会告诉我我的对象是什么类,但是我不能(例如)要求所有的对象是因素/数据。框架/函数等。

Will tell me what class my objects are, but I won't be able to (for example) ask for all the objects which are factors/data.frame/functions - and so on.

我可以捕获ls.str()的输出,但可能有一个更聪明的方式 - 任何想法是什么? / p>

I can capture.output of ls.str(), but probably there is a smarter way - any idea what it is?

推荐答案

这应该可以做到:

sapply(ls(), function(x){class(get(x))})

这篇关于环境中有什么类别的对象? (R)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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