我有一些数据存储在一个列表中,我尝试将下面的代码应用到其中:
library(tidyverse)
library(purrr)
library(BVAR)
mins <- map(df1, ~ .x / 100)
maxs <- map(df1, ~ .x * 100)
现在我有了3个列表,我想使用purrr
to pmap
函数对这些列表执行操作:
我的代码是以下这不工作:
pmap(
list(
mode = df1,
min = mins,
max = maxs
# scale = 0.004,
# shape = 0.004
),
~bv_psi(..1, ..2, ..3)
)
我们的想法是应用类似于:
bv_psi(scale = 0.004, shape = 0.004, mode = df1, min = min, max = max)
Shape / Scale: 0.004 / 0.004
#1 Mode / Bounds: 0.0000000001 / [0.000000000001, 0.00000001]
#2 Mode / Bounds: 2.329554 / [0.02329554, 232.9554]
#3 Mode / Bounds: 0.3086792 / [0.003086792, 30.86792]
#4 Mode / Bounds: 0.289515 / [0.00289515, 28.9515]
#5 Mode / Bounds: 0.3444753 / [0.003444753, 34.44753]
但所有的柱子。
数据:
df1 <- list(FRA = c(var1 = 0.348484926831081, var2 = 2.32955373143543,
var3 = 0.308679204532957, var4 = 0.242541092355223, var5 = 0.344475341669246
), ITA = c(var1 = 0.348484926831081, var2 = 2.26657313151514,
var3 = 0.34565008444245, var4 = 0.242541092355223, var5 = 0.403082188649582
), NOR = c(var2 = 1.20962811046986, var3 = 0.289000898298659,
var4 = 0.242541092355223, var5 = 0.34539772064608), SPA = c(var1 = 0.348484926831081,
var2 = 2.59042002848148, var3 = 0.748413615669766, var4 = 0.242541092355223,
var5 = 0.403082188649582), GER = c(var1 = 0.350388888258007,
var2 = 1.58267709209138, var3 = 0.230489915987761, var4 = 0.243815124309394,
var5 = 0.332742111113146))
2条答案
按热度按时间ar7v8xwq1#
可以使用
pmap
,名称列表在.l
中(如您所做的),但是scale
和shape
参数在...
中或者,您可以使用
~
样式调用bv_psi
,如下例所示:vaj7vani2#
map
调用中的另一个选项:输出: