这是我的列表:
declare namespace THREE{
export class DecalGeometry extends Geometry{
constructor(meshToIntersect: Geometry, position: Vector3, direction: Vector3, dimensions: Vector3, check?: Vector3);
}
}
在每个mylist=dput(mylist)
list(list(c(30, 50, 35, 25, 45), c(40, 35, 35, 50, 45), c(40,
20, 40, 50, 25), c(35, 45, 45, 45, 40), c(20, 30, 50, 45, 20),
c(40, 40, 50, 30, 40)), list(c(50, 50, 25, 40, 45, 40, 35,
40, 45, 20), c(40, 35, 40, 40, 45, 30, 20, 50, 35, 25), c(20,
30, 50, 35, 45, 40, 25, 50, 35, 50), c(20, 35, 30, 25, 40, 30,
50, 20, 25, 35), c(40, 25, 25, 20, 50, 30, 50, 40, 35, 35), c(50,
20, 45, 35, 50, 45, 30, 45, 35, 50)), list(c(45, 50, 25, 25,
30, 25, 35, 35, 35, 30, 50, 50, 30, 30, 20), c(40, 20, 35, 35,
50, 20, 25, 30, 35, 20, 40, 20, 45, 30, 20), c(50, 20, 25, 35,
35, 30, 50, 25, 40, 35, 45, 45, 35, 45, 25), c(50, 50, 25, 35,
25, 35, 20, 25, 45, 40, 35, 40, 50, 40, 30), c(50, 25, 20, 30,
40, 45, 40, 50, 35, 40, 30, 45, 35, 50, 40), c(35, 50, 35, 45,
25, 40, 50, 40, 50, 50, 50, 50, 35, 35, 40)), list(c(50, 50,
50, 40, 20, 25, 50, 40, 50, 50, 45, 40, 30, 50, 35, 45, 50, 30,
35, 45), c(45, 20, 25, 20, 25, 30, 20, 30, 45, 25, 50, 30, 30,
25, 50, 45, 20, 45, 45, 50), c(20, 40, 50, 25, 40, 45, 25, 30,
20, 20, 35, 45, 20, 40, 50, 45, 40, 40, 45, 35), c(40, 40, 20,
25, 50, 50, 35, 45, 50, 45, 50, 35, 30, 40, 35, 45, 25, 45, 45,
25), c(20, 25, 35, 45, 35, 40, 40, 35, 35, 40, 30, 30, 40, 50,
25, 40, 30, 25, 20, 40)), list(c(35, 25, 45, 20, 25, 30, 30,
35, 30, 40, 30, 20, 20, 30, 45, 40, 35, 35, 35, 35, 25, 45, 35,
20, 50), c(50, 35, 30, 30, 35, 45, 45, 50, 25, 25, 40, 25, 50,
45, 25, 30, 30, 25, 45, 45, 30, 20, 50, 30, 30), c(35, 40, 50,
25, 40, 45, 30, 25, 50, 25, 35, 50, 50, 50, 25, 50, 20, 50, 40,
25, 25, 35, 20, 20, 50), c(40, 35, 35, 40, 50, 35, 25, 40, 25,
25, 30, 45, 50, 35, 20, 50, 20, 20, 45, 50, 40, 30, 35, 50, 45
), c(40, 25, 50, 50, 20, 50, 25, 50, 40, 30, 30, 50, 45, 45,
40, 45, 20, 20, 45, 35, 45, 50, 40, 40, 35), c(40, 45, 35, 35,
30, 45, 40, 40, 20, 50, 50, 45, 40, 40, 45, 45, 35, 40, 20, 30,
35, 45, 30, 50, 25)))
(直到mylist[[1]][[1]],mylist[[1]][[2]],mylist[[3]][[1]],mylist[[1]][[4]],mylist[[1]][[5]],mylist[[1]][[6]]
位置)上,我都想运行ADF测试并使用Lapply函数提取其pvalue。
为此,我创建一个结果列表并运行以下代码:
mylist[[5]][[6]]
它不起作用。基本维护上面的lapply结构代码。
我能够通过这样做来提取均值(即使给了我重复的值,这也不是问题)
resultlist<-vector(mode = "list", 5)
# library( _enter_name_of_package )
resultlist <- lapply(mylist,
function(x)
lapply(x, function(y) rep(adf.test(mylist)$p.value(y), length(y))))
考虑到此代码,我想运行ADF测试并提取pvalue。
答案 0 :(得分:1)
通常,如果要对列表列表的每个元素(此处为myfun
)应用函数(此处为mylist
),请执行以下操作:
lapply(mylist, lapply, myfun)
这将返回列表结果,您可以使用unlist
将其转换为向量。
我不确定您要为特定应用程序使用哪个adf.test
函数,因为tseries
和aTSA
包中都有此名称的函数(也许其他)。无论如何,解决方案将如下所示:
lapply(mylist, lapply, function(x) adf.test(x)$p.value)