filtering data.frame based on row_number()

后端 未结 3 933
旧巷少年郎
旧巷少年郎 2021-02-01 14:01

UPDATE: dplyr has been updated since this question was asked and now performs as the OP wanted

I´m trying to get the second to the seventh line in a

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 14:18

    Here is another way to do row-number based filtering in a pipeline.

        df <- data.frame(id = 1:10, var = runif(10))
    
        df %>% .[2:7,]
    
        > id     var
          2  2 0.28817
          3  3 0.56672
          4  4 0.96610
          5  5 0.74772
          6  6 0.75091
          7  7 0.05165
    

提交回复
热议问题