r - 管道操作结束时的相关性
问题描述
我试图在管道操作结束时获得两个变量之间的相关性,为什么这些不起作用?
library(tidyverse)
iris %>%
map(~cor(.$Sepal.Length, .$Sepal.Width, use = "complete.obs"))
#or
iris %>%
dplyr::select(Sepal.Length, Sepal.Width) %>%
map2(~cor(.x, .y, use = "complete.obs"))
谢谢
解决方案
别忘了%$%
!
library(magrittr)
iris %$%
cor(Sepal.Length, Sepal.Width, use = "complete.obs")
#> [1] -0.1175698
由reprex 包(v0.3.0)于 2021-03-02 创建
推荐阅读
- mysql - MySQL:将值从案例表达式插入表中
- amazon-web-services - 使用 Docker、Nginx、AWS ECS 进行 LetsEncrypt 验证有一半时间失败
- r - for循环在r中写入多个数据帧
- python - seek() 无法正常工作,尽管文件以“r”模式打开
- reactjs - react native - 应用程序在后台运行时崩溃(日志中没有错误)
- chapel - 我可以在 Chapel 中使用数组作为配置常量吗
- kerberos - 自定义翻译器中没有用户主体广告 TEIID JDBC
- c - Linux中的可用(免费)磁盘空间显示为负数?
- pyomo - pyomo 隐式替换 Component 属性
- excel - vba 比较相似列表