尝试grouped_df通过索引选择类对象的列给出"错误:索引超出范围".例如
x <- mtcars %>% group_by(am, gear) %>% summarise_each(funs(sum), disp, hp, drat)
class(x)
# "grouped_df" "tbl_df" "tbl" "data.frame"
# For some reason the first column can be selected...
x[1]
# Source: local data frame [4 x 1]
# Groups: am
# am
# 0
# 0
# 1
# 1
# ...but any index > 1 fails
x[2]
# Error: index out of bounds
# Coercing to data frame does the trick...
as.data.frame(x)[2]
# gear
# 3
# …Run Code Online (Sandbox Code Playgroud)