全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
33546 3
2011-07-03
R中$是什么意思?
eps = data.frame(sim$eps[[1]], sim$eps[[2]], sim$eps[[3]]) # encapsulate

例如以上中的$是做什么用的?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-7-3 18:17:08
详细可以看一下help

?"$"

Extract or Replace Parts of an Object
Description
Operators acting on vectors, matrices, arrays and lists to extract or replace parts.

以eps为例说明

?vBEKK.sim

Value

A list of class "mvBEKK.sim" with the following elements: length length of the series simulated

order               order of the BEKK model
params           a vector of the selected parameters
true.params    list of parameters in matrix form
eigenvalues    computed eigenvalues for sum of Kronecker products
uncond.cov.matrix unconditional covariance matrix of the process
white.noise    white noise series used for simulating the process
eps                  a list of simulated series
cor                    list of series of conditional correlations
sd                    list of series of conditional standard deviations

所以知道 eps 是  a list of simulated series

###
sim = mvBEKK.sim(series.count = 3, T =100)
names(sim)
# [1] "length"            "series.count"      "order"             "params"           
# [5] "true.params"       "eigenvalues"       "uncond.cov.matrix" "white.noise"      
# [9] "eps"               "cor"               "sd"

sim$eps
#[[1]]
#  [1] -0.19612661 -0.64480093  1.62395655 -0.33026064 -0.34676227


#[[2]]
#  [1]  1.78685217 -0.62248325  0.96838894  0.73833425  1.66785995


#[[3]]
#  [1] -0.810340036  1.756455758 -1.444400841 -2.353201553 -0.639545512

sim$eps[[1]][1:5]
#[1] -0.1961266 -0.6448009  1.6239565 -0.3302606 -0.3467623
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-3 22:41:54
sim$eps[[1]][1:5]

非常感谢epoh大师!
学生还想再问一句:为什么要在[[1]][1:5]中[[1]]要加两对方括号呢?非常感谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-3 23:43:20
list的用法是[[1]]
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群