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

  • Home
  • SEARCH
  • 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 8288523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:17:57+00:00 2026-06-08T12:17:57+00:00

I have 9880 records in a data frame, I am trying to split it

  • 0

I have 9880 records in a data frame, I am trying to split it into 9 groups of 1000 each and the last group will have 880 records and also name them accordingly. I used for-loop for 1-9 groups but manually for the last 880 records, but i am sure there are better ways to achieve this,

library(sqldf)
for (i in 0:8)
{
assign(paste("test",i,sep="_"),as.data.frame(final_9880[((1000*i)+1):(1000*(i+1)),   (1:53)]))
}
test_9<- num_final_9880[9001:9880,1:53]

also am unable to append all the parts in one for-loop!

#append all parts
all_9880<-rbind(test_0,test_1,test_2,test_3,test_4,test_5,test_6,test_7,test_8,test_9)

Any help is appreciated, thanks!

  • 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-08T12:17:58+00:00Added an answer on June 8, 2026 at 12:17 pm

    A small variation on this solution

    ls <- split(final_9880, rep(0:9, each = 1000, length.out = 9880))  # edited to Roman's suggestion
    for(i in 1:10) assign(paste("test",i,sep="_"), ls[[i]])
    

    Your command for binding should work.

    Edit

    If you have many dataframes you can use a parse-eval combo. I use the package gsubfn for readability.

    library(gsubfn)
    nms <- paste("test", 1:10, sep="_", collapse=",")
    eval(fn$parse(text='do.call(rbind, list($nms))'))
    

    How does this work? First I create a string containing the comma-separated list of the dataframes

    > paste("test", 1:10, sep="_", collapse=",")
    [1] "test_1,test_2,test_3,test_4,test_5,test_6,test_7,test_8,test_9,test_10"
    

    Then I use this string to construct the list

    list(test_1,test_2,test_3,test_4,test_5,test_6,test_7,test_8,test_9,test_10)
    

    using parse and eval with string interpolation.

    eval(fn$parse(text='list($nms)'))
    

    String interpolation is implemented via the fn$ prefix of parse, its effect is to intercept and substitute $nms with the string contained in the variable nms. Parsing and evaluating the string "list($mns)" creates the list needed. In the solution the rbind is included in the parse-eval combo.

    EDIT 2

    You can collect all variables with a certain pattern, put them in a list and bind them by rows.

    do.call("rbind", sapply(ls(pattern = "test_"), get, simplify = FALSE))
    

    ls finds all variables with a pattern “test_”

    sapply retrieves all those variables and stores them in a list

    do.call flattens the list row-wise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have data that has this kind of structure. Will be in ascending order by
I have a file that is organized into columns, with data that needs to
Have a painfully simple blog Post creator, and I'm trying to check if the
have a nice day. I got problem when trying to create an image from
have been trying couple of hours now to make my iphone app universal. The
Have one Doubt In MVC Architecture we can able to pass data from Controller
Have data that has this kind of structure: $input = [ { animal: 'cat',
Have just started to get into CakePHP since a couple of weeks back. I
Have a xml data like <Items><Item><name>test1</name></Item><Item><name>test2</name></Item></Items> Looks like jaxb cannot unmashall this when defining
Have whats probably a simple problem with using parent in if and each statements

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.