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 9178499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:33:58+00:00 2026-06-17T17:33:58+00:00

I have a large list of objects (say 100k elements). Each element will have

  • 0

I have a large list of objects (say 100k elements). Each element will have to be processed by a function “process” BUT I would like to do the processing in chunks… say 20 passes for example as I want to save processing results into a hard drive file and keep operating memory free.

I’m new to R and I know that it should involve some apply magic but I don’t know how to do it (yet).

Any guidance would be much appreciated.

A small example:

 objects <- list();
 for (i in 1:100){
 objects <- append(objects, 500);
 }
 objects;





 processOneElement <- function(x){
 x/20 + 23;
 }

I would like to process first 20 elements in one go and save results then process second 20 elements in second go and save results… and so on

objects <- list();
 for (i in 1:100){
 objects <- append(objects, 500);
 }
 objects;

process <- function(x){
 x/20 + 23;
 }

results <- lapply(objects, FUN=process)



index <- seq(1, length(objects), by=20);
lapply(index, function(idx1) {
idx2 <- min(idx1+20-1, length(objects));
batch <- lapply(idx:idx2, function(x) {
process(objects[[x]]);
})

write.table(batch, paste("batch", idx1, sep=""));
})
  • 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-17T17:33:59+00:00Added an answer on June 17, 2026 at 5:33 pm

    With what you have given, this is the answer I could suggest. Assuming your list is stored in list.object,

    lapply(seq(1, length(list.object), by=20), function(idx) {
        # here idx will be 1, 21, 41 etc...
        idx2 <- min(idx+20-1, length(list.object))
        # do what you want here.. 
        batch.20.processed <- lapply(idx:idx2, function(x) {
            process(list.object[[x]]) # passes idx:idx2 indices one at a time
        })
        # here you have processed list with 20 elements
        # finally write to file
        lapply(1:20, function(x) {
            write.table(batch.20.processed[[x]], ...)
            # where "..." is all other allowed arguments to write.table
            # such as row.names, col.names, quote etc.
            # don't literally pass "..." to write.table
        })
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large list [[1,.., ..],[2,...,...],[5,...,...],[1,...,...]] I need to remove all elements that
Let's say I have a somewhat large (several millions of items, or so) list
Let's say I have a collection of Person objects, each of which looks like
I have a large array with around 20k objects in it. Each object has
I know STL containers copy the objects. So say I have a list<SampleClass> l;
I have a large list of objects inside JSON like this: var data =
I have a large list of objects, all of whom have a path to
I have a social-clique-object. In each social-clique-object I have a list of friend-objects. Each
I have a large list of email addresses, and I need to determine which
I have a large list of file names that are illegal, I want to

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.