首页 > 其他 > 详细

R中list对象属性以及具有list性质的对象

时间:2015-10-19 17:17:29      阅读:244      评论:0      收藏:0      [点我收藏+]

技术分享

R语言list的特点:It has length[[ and [ methods, and is recursive because list can contain other list!上图显示了操作符 [[和[的区别!---[返回结果依旧是一个list但是[[已经不是一个list了

》》具有list属性的类还有

1、call类对象:The first element of the call is the function that gets called. It’s usually the name of a function:

> x <- quote(read.csv("important.csv", row.names = FALSE))
> class(x)
[1] "call"
> lenth(x)

2、formula 类的对象

dat=data.frame(x1=rnorm(100,m=50),x2=rnorm(100,m=50),x3=rnorm(100,m=50),x4=rnorm(100,m=50),y=rnorm(100))
m2=lm(y~log(x1)+x2*x3,data=dat)
newFmla=formula(m2)
> class(newFmla)
[1] "formula"
> length(newFmla)
[1] 3
> newFmla[1]
`~`()
> newFmla[2]
y()
> newFmla[3]
(log(x1) + x2 * x3)()

 

R中list对象属性以及具有list性质的对象

原文:http://www.cnblogs.com/amazement/p/4892303.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!