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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:00:26+00:00 2026-06-07T09:00:26+00:00

This is not homework, just a learning exercise on my part. I have been

  • 0

This is not homework, just a learning exercise on my part. I have been running a very simple simulation (or number-crank) in R. It generates two numbers (A, B) and runs for 1 month.

A=NULL
B=NULL
x=NULL
x <- Sys.time()
duration <-  2592000 # 30 days
while(Sys.time() <= x + duration){
A <-append(A, sample(1:5, 1000, 1/5))
B <-append(B, sample(1:5, 1000, 1/5))
save.image()
}

I thought it was going well, but after one week (and several million numbers generated) the OS killed the process. Is there a better way of writing or running the simulation that would prevent the OS killing it?

I would prefer to rewrite the simulation than to adapt the OS (such as adding more swap etc). I am running the simulation on a low-powered device (Raspberry Pi) and am limited in what I can do on the hardware side. Thanks.

UPDATE:
1) It is not important that the samples be generated 1000 at a time. This was just my cludge.
2) It is important that the simulation runs for a set period of time ie 1 week, 1 month or 1 year.
3) Unless impossible I want the raw data.

  • 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-07T09:00:28+00:00Added an answer on June 7, 2026 at 9:00 am

    If you consider printing out the result on paper as an acceptable solution, then Roman Luštrik’s solution (in the comments to your question) of appending your data to a text-file or a database is definitely one good solution.

    Here is what appending to a text-file would look like:

    x <- Sys.time()
    duration <-  2592000
    while(Sys.time() <= x + duration){
        write.table(sample(1:5, 1000, 1/5),file="A.txt",append=TRUE,row.names=FALSE,col.names=FALSE,sep="\t")
        write.table(sample(1:5, 1000, 1/5),file="B.txt",append=TRUE,row.names=FALSE,col.names=FALSE,sep="\t")
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this one is not homework, it just the fact that i've been out of
This is not homework, just a question about my code (I'm learning C++). I
I'm trying to solve this problem, its not a homework question, its just code
This is not a homework. Just an interesting task :) Given a complete binary
Yes, this will be a homework (I am self-learning not for university) question but
First of all, this is not homework! :) Say I have an NSString: the?or?
Just to clarify this is NOT a homework question as I've seen similar accusations
For those with suspicious minds, this is not homework, just curious. Given a finite
I have a few questions. Yes this is homework and I am just trying
This is not homework, I need this for my program :) I ask this

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.