这里有一个解决方案(返回未排序的尾部):
tbl_df(batting_tbl) %>% slice(101282:101332) # Prints the last 50 rows
下面是第二种解决方案(过滤器索引):
tbl_df(batting_tbl) %>% arrange(-as.numeric(rownames(.))) %>% head(., n = 50)
**注:以上两项要求
tbl_df
鉴于
batting_tbl %>% head(., n = 50)
不需要收集R数据。并且往往花费更少的时间来计算。感谢@user6910411指出
monotonically_increasing_id()
或者类似的东西将返回火花数据帧而不是R数据。返回的帧
collect()
.
sdf_with_unique_id(batting_tbl, id = "id") %>% arrange(-id) # Id column for sorting