码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-10-19 17:20:45      阅读:201      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!