How do you use approx() inside of mutate_at()?

﹥>﹥吖頭↗ 提交于 2019-12-06 04:33:49

You're very close. This works for me:

joineddemotblswithinterpolation <- joineddemotbls %>%
  group_by(groupvar) %>%
  mutate_at(vars(starts_with("x")), # easier than listing each column separately
            funs("i" = approx(timevar, ., timevar, rule = 2, f = 0, ties = mean,
                              method = "linear")[["y"]]))

This will create columns x1_i, x2_i etc. with the interpolated values.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!