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.
r loops simulation
add a comment |
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.
r loops simulation
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
add a comment |
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.
r loops simulation
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
r loops simulation
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
add a comment |
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
add a comment |
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)
This seems a quick fix. Thanks!
– amisos55
Nov 11 at 0:46
add a comment |
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)
This seems a quick fix. Thanks!
– amisos55
Nov 11 at 0:46
add a comment |
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)
This seems a quick fix. Thanks!
– amisos55
Nov 11 at 0:46
add a comment |
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)
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)
answered Nov 9 at 21:49
MatAff
512213
512213
This seems a quick fix. Thanks!
– amisos55
Nov 11 at 0:46
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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