Magrittr %T>% Pipe Help

I just want to know why this code produces one result on console and one plot just as I expected

mtcars %>% 
  select(hp, mpg) %T>% 
  print() %>% 
  plot()

But this code doesn't

library(plotluck)
library(skimr)
mtcars %>% 
  select(hp, mpg) %T>% 
  skim() %>% 
  plotluck(data = ., hp ~ mpg)

Can anybody please point out what am I doing wrong??

I think you just need to use skimr::skim_tee

mtcars %>% 
  select(hp, mpg) %T>% 
  skim_tee() %>% 
  plotluck(data = ., hp ~ mpg)

As explained in the doc,

skim will return a tibble and does not print by itself. That is why you get nothing. skim_tee will do that for you by printing the result before returning it explicitly.

Hope it helps.

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.