Splitting a large data frame into smaller segments

后端 未结 5 792
你的背包
你的背包 2020-12-01 09:17

I have the following data frame and I want to break it up into 10 different data frames. I want to break the initial 100 row data frame into 10 data frames of 10 rows. I cou

5条回答
  •  误落风尘
    2020-12-01 09:57

    If you can generate a vector that defines the groups, you can split anything:

    f <- rep(seq_len(ceiling(1123 / 200)),each = 200,length.out = 1123)
    > df1 <- split(df,f = f)
    > lapply(df1,dim)
    $`1`
    [1] 200   3
    
    $`2`
    [1] 200   3
    
    $`3`
    [1] 200   3
    
    $`4`
    [1] 200   3
    
    $`5`
    [1] 200   3
    
    $`6`
    [1] 123   3
    

提交回复
热议问题