我不能在dplyr中使用mutate后的过滤器

时间:2015-03-12 12:02:27

标签: r dplyr

我无法弄清楚为什么我可以让它发挥作用。

datos = data.frame(año = 2001:2005, gedad = c(letters[1:5]))  
datos %>% mutate(año2 = año*1) %>% filter(año2 >= 2003)

错误说:

 Error in filter_impl(.data, dots) : object 'año2' not found

仅仅是因为我不能使用带有变异变换的变量的过滤器?

子集正常工作:

datos %>% mutate(año2 = año*1) %>% subset(año2>=2003)
R说:

   año gedad año2
3 2003     c 2003
4 2004     d 2004
5 2005     e 2005

提前致谢!

0 个答案:

没有答案
相关问题