你需要在变异中分配变化。如果不使用mutate dplyr中的assign,那么将创建一个头部与整个函数相同的列。
df %>%
mutate(rounded_dates = lubridate::round_date(sunset, unit="minute"))
无赋值和有赋值的mutate示例,请参见末尾的列名:
iris %>%
mutate(Sepal.Length + Sepal.Width)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species Sepal.Length + Sepal.Width
1 5.1 3.5 1.4 0.2 setosa 8.6
2 4.9 3.0 1.4 0.2 setosa 7.9
.....
iris %>%
mutate(addition = Sepal.Length + Sepal.Width)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species addition
1 5.1 3.5 1.4 0.2 setosa 8.6
2 4.9 3.0 1.4 0.2 setosa 7.9