我有以下数据框(抱歉没有提供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)