Pipe a data frame to a function whose argument pipes a dot

前端 未结 1 1448
离开以前
离开以前 2021-01-18 07:28

How can one pipe a data frame to a function whose argument pipes a dot?

mpg %>% rbind(., . %>% rev())

Error in rep(xi,

1条回答
  •  日久生厌
    2021-01-18 08:20

    Wrap the dot to be piped in parentheses like (.):

    mpg %>% rbind(., (.) %>% rev())
    

    Or, for lambda function:

    mpg %>%
      {
        (.) %>% arrange(manufacturer)
      }
    

    0 讨论(0)
提交回复
热议问题