小编Vin*_*ent的帖子

Dplyr:对包含列表的列使用mutate

我有以下数据框(抱歉没有提供dput的示例,当我在此处粘贴时,它似乎不适用于列表):

数据

现在,我想创建一个新列y是需要之间的区别mnt_ope,并ref_amount为每一个元素ref_amount.结果将是每行中具有与相应值相同的元素数量的列表ref_amount.

我试过了:

data <- data %>%
   mutate( y = mnt_ope - ref_amount)
Run Code Online (Sandbox Code Playgroud)

但是我得到了错误:

Evaluation error: non-numeric argument to binary operator.

dput:

structure(list(mnt_ope = c(500, 500, 771.07, 770.26, 770.26, 
770.26, 770.72, 770.72, 770.72, 770.72, 770.72, 779.95, 779.95, 
779.95, 779.95, 2502.34, 810.89, 810.89, 810.89, 810.89, 810.89
), ref_amount = list(c(500, 500), c(500, 500), c(771.07, 770.26, 
770.26), c(771.07, 770.26, 770.26), c(771.07, 770.26, 770.26), 
    c(771.07, 770.26, 770.26), c(771.07, 770.26, 770.26), c(771.07, …
Run Code Online (Sandbox Code Playgroud)

r dplyr

6
推荐指数
1
解决办法
334
查看次数

标签 统计

dplyr ×1

r ×1