Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9088927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:01:08+00:00 2026-06-16T22:01:08+00:00

I have the following data frame and I want to break it up into

  • 0

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 could do the following and get the desired results.

df = data.frame(one=c(rnorm(100)), two=c(rnorm(100)), three=c(rnorm(100)))

df1 = df[1:10,]
df2 = df[11:20,]
df3 = df[21:30,]
df4 = df[31:40,]
df5 = df[41:50,]
...

Of course, this isn’t an elegant way to perform this task when the initial data frames are larger or if there aren’t an easy number of segments that it can be broken down into.

So given the above, let’s say we have the following data frame.

df = data.frame(one=c(rnorm(1123)), two=c(rnorm(1123)), three=c(rnorm(1123)))

Now I want to split it into new data frames comprised of 200 rows, and the final data frame with the remaining rows. What would be a more elegant (aka ‘quick’) way to perform this task.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:01:09+00:00Added an answer on June 16, 2026 at 10:01 pm
     > str(split(df, (as.numeric(rownames(df))-1) %/% 200))
    List of 6
     $ 0:'data.frame':  200 obs. of  3 variables:
      ..$ one  : num [1:200] -1.592 1.664 -1.231 0.269 0.912 ...
      ..$ two  : num [1:200] 0.639 -0.525 0.642 1.347 1.142 ...
      ..$ three: num [1:200] -0.45 -0.877 0.588 1.188 -1.977 ...
     $ 1:'data.frame':  200 obs. of  3 variables:
      ..$ one  : num [1:200] -0.0017 1.9534 0.0155 -0.7732 -1.1752 ...
      ..$ two  : num [1:200] -0.422 0.869 0.45 -0.111 0.073 ...
      ..$ three: num [1:200] -0.2809 1.31908 0.26695 0.00594 -0.25583 ...
     $ 2:'data.frame':  200 obs. of  3 variables:
      ..$ one  : num [1:200] -1.578 0.433 0.277 1.297 0.838 ...
      ..$ two  : num [1:200] 0.913 0.378 0.35 -0.241 0.783 ...
      ..$ three: num [1:200] -0.8402 -0.2708 -0.0124 -0.4537 0.4651 ...
     $ 3:'data.frame':  200 obs. of  3 variables:
      ..$ one  : num [1:200] 1.432 1.657 -0.72 -1.691 0.596 ...
      ..$ two  : num [1:200] 0.243 -0.159 -2.163 -1.183 0.632 ...
      ..$ three: num [1:200] 0.359 0.476 1.485 0.39 -1.412 ...
     $ 4:'data.frame':  200 obs. of  3 variables:
      ..$ one  : num [1:200] -1.43 -0.345 -1.206 -0.925 -0.551 ...
      ..$ two  : num [1:200] -1.343 1.322 0.208 0.444 -0.861 ...
      ..$ three: num [1:200] 0.00807 -0.20209 -0.56865 1.06983 -0.29673 ...
     $ 5:'data.frame':  123 obs. of  3 variables:
      ..$ one  : num [1:123] -1.269 1.555 -0.19 1.434 -0.889 ...
      ..$ two  : num [1:123] 0.558 0.0445 -0.0639 -1.934 -0.8152 ...
      ..$ three: num [1:123] -0.0821 0.6745 0.6095 1.387 -0.382 ...
    

    If some code might have changed the rownames it would be safer to use:

     split(df, (seq(nrow(df))-1) %/% 200) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following data: a=c(1:10) b=c(16:25) c=c(24:33) wa=c(3,7,3,3,3,3,3,3,3,1) wb=c(3,2,3,3,3,3,3,3,3,8) wc=c(4,1,4,4,4,4,4,4,4,1) z=data.frame(a,b,c,wa,wb,wc) I want
I have the following data.frames: a <- data.frame(id = 1:3, v1 = c('a', NA,
I have the following dataframe: sp <- combn(c(sp1,sp2,sp3,sp4),2) d <- data.frame(t(sp),freq=sample(0:100,6)) and two factors
I have the following data frame and i want to use cast to create
I have the following data frame: id<-c(1,2,3,4) x<-c(0,2,1,0) A<-c(1,3,4,3) df<-data.frame(id,x,A) now I want to
I have the following data frame in IPython, where each row is a single
I have the following data frame that I want to order by the fifth
I have following issue, I could solve: set.seed (1234) mydf <- data.frame (var1a =
I have the following dummy code: dt<-data.frame(country=letters[1:20],val=rnorm(20),siz=rnorm(20)) qplot(x=country,y=val,data=dt,geom=point,size=siz) Now I want to increase the
Suppose I have the following data frame: Data1 X1 X2 1 15 1 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.