【问题标题】:Is there a shorter alternative to write "df <- df %>%" in dplyr/tidyverse?在 dplyr/tidyverse 中是否有更短的替代方法来编写“df <- df %>%”?
【发布时间】:2022-06-15 04:25:41
【问题描述】:

当我想更新变量“df”时,我总是写两次df,如下所示。

df <- df %>% mutate(new column = 'new') 

但我觉得两次写 df 是多余的,我想知道是否有更短的替代方案,例如

df <-> mutate(new column = 'new')

谢谢!

【问题讨论】:

  • 是的,使用来自 magrittr 的 %&lt;&gt;% 运算符,即 df %&lt;&gt;% mutate(newcolumn = 'new')

标签: r dplyr tidyverse


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-02-28
  • 2017-07-31
  • 2017-12-21
  • 1970-01-01
  • 1970-01-01
  • 2018-09-15
  • 2022-10-06
相关资源
最近更新 更多