I am trying to get a correlation between two variables at the end of a pipe operation, why don't these work?
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"))
thanks
Don't forget about %$%
!
library(magrittr)
iris %$%
cor(Sepal.Length, Sepal.Width, use = "complete.obs")
#> [1] -0.1175698
Created on 2021-03-02 by the reprex package (v0.3.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With