为什么分组的data_frame / tbl的对象属性中的索引从0开始而不是像R中通常那样从1开始索引?如果我想获得“正确的” R索引,则必须添加1。请参见下面的代码以更好地理解:
#Basic way of getting indices:
> which(mtcars$cyl==6)
[1] 1 2 4 6 10 11 30
#Group by and use attr(*, 'indices') to try and get indices:
> cars_group_by <- group_by(mtcars, cyl)
> attr(cars_group_by, 'indices')[2]
[[1]]
[1] 0 1 3 5 9 10 29