变异功能未更新 [英] mutate function is not updating

查看:51
本文介绍了变异功能未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 tbl_df ,其中有几列。我正在运行一个简单的mutate来更新一列,但是该列没有被更新。

I have a tbl_df with several columns. I am running a simple mutate on it to update a column, but the column is not being updated.

mutate(fltr, cat = "xxxxx")

cat empty NA 。过滤器是 tbl_df 。是什么原因造成的?我试图将文本放在 cat 列中,以使其不为空或不适用,以防引起问题。仍然不起作用。

cat is a column that is either empty or NA. Filter is a tbl_df. What could be causing this? I have tried to put text in the cat column so that it is not empty or NA in case that was causing the problem. That still did not work.

推荐答案

正如@DavidRobinson指出的那样,您没有将其分配回同一对象。为了避免重新分配,我们可以使用magrittr的复合分配管道运算符-%<>%

As @DavidRobinson pointed out, you are not assigning it back to the same object. To avoid reassigning we could use magrittr's compound assignment pipe-operator - %<>% :

require(dplyr)
require(magrittr)

fltr %<>% mutate(cat="xxxxx")

这篇关于变异功能未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆