R-列表中所有数据帧的相关性测试

R-列表中所有数据帧的相关性测试,r,list,lapply,R,List,Lapply,我有一个列表(top30clean),其中包含21个数据帧,标记为b1到b21,每个数据帧都有三个变量-站,降雨,原点 我希望对相同的两个变量raining&Origin cor <- lapply(top30clean, cor(top30clean$Rainfall, top30clean$Origin, method = c('pearson') cor在lappy中使用匿名函数: cor <- lapply(top30clean, function(x) cor(x$Rai

我有一个列表(top30clean),其中包含21个数据帧,标记为
b1
b21
,每个数据帧都有三个变量-
降雨
原点

我希望对相同的两个变量
raining
&
Origin

cor <- lapply(top30clean, cor(top30clean$Rainfall, top30clean$Origin, method = c('pearson')

cor在
lappy
中使用匿名函数:

cor <- lapply(top30clean, function(x) cor(x$Rainfall, x$Origin, method = 'pearson'))

cor我们可以使用
map

library(purrr)
map(top30clean, ~  cor(.x$Rainfall, .x$Origin, method = 'pearson'))

操,是的,你太棒了