How to save or read files inside of a simulation









up vote
-1
down vote

favorite












I am trying to run a simulation. There are certain files that I need to save and sometimes read from inside of the simulation. I have three sample size conditions and I am giving names based on the sample sizes.



For example, the file name is "binAll.100.dne" and this is for sample size 100.



Do you have any thoughts on how to save or read this sort files based on differing simulation conditions? Here is my shellcode. I am trying to save an object "binAll" as "binAll.100.dne" and N is my sample size, which is 100 here.



start.time = proc.time()

Ns = c(100, 400, 900) # sample sizes
Iterations = 300 #number of iterations/datasets

for (N in Ns)

#store the results in an empty vector
all.results <- c()

for (iter in 1:Iterations)
# ALL FUNCTIONS GO HERE
WriteNetworks(binAll,"binAll.100.dne") # how to save this seperately for each sample size

#close dataset loop

# save the results outside of the dataset loop
write.table(all.results, file="simulation_results.csv", sep=",", append=T,col.names=F,row.names=F,quote=F)

#close the sample size loop

end.time = proc.time()
total.time = end.time - start.time


Thanks for taking your time.
Cheers.










share|improve this question





















  • What exactly is the problem to solve? "how to save or read files based on ... conditions" is very vague... Please edit your questions. THX!
    – R Yoda
    Nov 9 at 21:05














up vote
-1
down vote

favorite












I am trying to run a simulation. There are certain files that I need to save and sometimes read from inside of the simulation. I have three sample size conditions and I am giving names based on the sample sizes.



For example, the file name is "binAll.100.dne" and this is for sample size 100.



Do you have any thoughts on how to save or read this sort files based on differing simulation conditions? Here is my shellcode. I am trying to save an object "binAll" as "binAll.100.dne" and N is my sample size, which is 100 here.



start.time = proc.time()

Ns = c(100, 400, 900) # sample sizes
Iterations = 300 #number of iterations/datasets

for (N in Ns)

#store the results in an empty vector
all.results <- c()

for (iter in 1:Iterations)
# ALL FUNCTIONS GO HERE
WriteNetworks(binAll,"binAll.100.dne") # how to save this seperately for each sample size

#close dataset loop

# save the results outside of the dataset loop
write.table(all.results, file="simulation_results.csv", sep=",", append=T,col.names=F,row.names=F,quote=F)

#close the sample size loop

end.time = proc.time()
total.time = end.time - start.time


Thanks for taking your time.
Cheers.










share|improve this question





















  • What exactly is the problem to solve? "how to save or read files based on ... conditions" is very vague... Please edit your questions. THX!
    – R Yoda
    Nov 9 at 21:05












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I am trying to run a simulation. There are certain files that I need to save and sometimes read from inside of the simulation. I have three sample size conditions and I am giving names based on the sample sizes.



For example, the file name is "binAll.100.dne" and this is for sample size 100.



Do you have any thoughts on how to save or read this sort files based on differing simulation conditions? Here is my shellcode. I am trying to save an object "binAll" as "binAll.100.dne" and N is my sample size, which is 100 here.



start.time = proc.time()

Ns = c(100, 400, 900) # sample sizes
Iterations = 300 #number of iterations/datasets

for (N in Ns)

#store the results in an empty vector
all.results <- c()

for (iter in 1:Iterations)
# ALL FUNCTIONS GO HERE
WriteNetworks(binAll,"binAll.100.dne") # how to save this seperately for each sample size

#close dataset loop

# save the results outside of the dataset loop
write.table(all.results, file="simulation_results.csv", sep=",", append=T,col.names=F,row.names=F,quote=F)

#close the sample size loop

end.time = proc.time()
total.time = end.time - start.time


Thanks for taking your time.
Cheers.










share|improve this question













I am trying to run a simulation. There are certain files that I need to save and sometimes read from inside of the simulation. I have three sample size conditions and I am giving names based on the sample sizes.



For example, the file name is "binAll.100.dne" and this is for sample size 100.



Do you have any thoughts on how to save or read this sort files based on differing simulation conditions? Here is my shellcode. I am trying to save an object "binAll" as "binAll.100.dne" and N is my sample size, which is 100 here.



start.time = proc.time()

Ns = c(100, 400, 900) # sample sizes
Iterations = 300 #number of iterations/datasets

for (N in Ns)

#store the results in an empty vector
all.results <- c()

for (iter in 1:Iterations)
# ALL FUNCTIONS GO HERE
WriteNetworks(binAll,"binAll.100.dne") # how to save this seperately for each sample size

#close dataset loop

# save the results outside of the dataset loop
write.table(all.results, file="simulation_results.csv", sep=",", append=T,col.names=F,row.names=F,quote=F)

#close the sample size loop

end.time = proc.time()
total.time = end.time - start.time


Thanks for taking your time.
Cheers.







r loops simulation






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 9 at 20:53









amisos55

9218




9218











  • What exactly is the problem to solve? "how to save or read files based on ... conditions" is very vague... Please edit your questions. THX!
    – R Yoda
    Nov 9 at 21:05
















  • What exactly is the problem to solve? "how to save or read files based on ... conditions" is very vague... Please edit your questions. THX!
    – R Yoda
    Nov 9 at 21:05















What exactly is the problem to solve? "how to save or read files based on ... conditions" is very vague... Please edit your questions. THX!
– R Yoda
Nov 9 at 21:05




What exactly is the problem to solve? "how to save or read files based on ... conditions" is very vague... Please edit your questions. THX!
– R Yoda
Nov 9 at 21:05












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










From what I understand you are trying to base filenames on the sample sizes. You could do this by using the paste() method to concatenate the filename and sample size. See the example below. If this is not what you are after please update your question.



N <- 100 # Set sample size

# Create filename
fileName <- paste("binAll", N, "dne", sep=".")
print(fileName)

# Example write function
write.table(yourData, file=fileName)





share|improve this answer




















  • This seems a quick fix. Thanks!
    – amisos55
    Nov 11 at 0:46










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233135%2fhow-to-save-or-read-files-inside-of-a-simulation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










From what I understand you are trying to base filenames on the sample sizes. You could do this by using the paste() method to concatenate the filename and sample size. See the example below. If this is not what you are after please update your question.



N <- 100 # Set sample size

# Create filename
fileName <- paste("binAll", N, "dne", sep=".")
print(fileName)

# Example write function
write.table(yourData, file=fileName)





share|improve this answer




















  • This seems a quick fix. Thanks!
    – amisos55
    Nov 11 at 0:46














up vote
1
down vote



accepted










From what I understand you are trying to base filenames on the sample sizes. You could do this by using the paste() method to concatenate the filename and sample size. See the example below. If this is not what you are after please update your question.



N <- 100 # Set sample size

# Create filename
fileName <- paste("binAll", N, "dne", sep=".")
print(fileName)

# Example write function
write.table(yourData, file=fileName)





share|improve this answer




















  • This seems a quick fix. Thanks!
    – amisos55
    Nov 11 at 0:46












up vote
1
down vote



accepted







up vote
1
down vote



accepted






From what I understand you are trying to base filenames on the sample sizes. You could do this by using the paste() method to concatenate the filename and sample size. See the example below. If this is not what you are after please update your question.



N <- 100 # Set sample size

# Create filename
fileName <- paste("binAll", N, "dne", sep=".")
print(fileName)

# Example write function
write.table(yourData, file=fileName)





share|improve this answer












From what I understand you are trying to base filenames on the sample sizes. You could do this by using the paste() method to concatenate the filename and sample size. See the example below. If this is not what you are after please update your question.



N <- 100 # Set sample size

# Create filename
fileName <- paste("binAll", N, "dne", sep=".")
print(fileName)

# Example write function
write.table(yourData, file=fileName)






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 9 at 21:49









MatAff

512213




512213











  • This seems a quick fix. Thanks!
    – amisos55
    Nov 11 at 0:46
















  • This seems a quick fix. Thanks!
    – amisos55
    Nov 11 at 0:46















This seems a quick fix. Thanks!
– amisos55
Nov 11 at 0:46




This seems a quick fix. Thanks!
– amisos55
Nov 11 at 0:46

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233135%2fhow-to-save-or-read-files-inside-of-a-simulation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Syphilis

Darth Vader #20