I run my script one time for example and firstly I obtain one matrix mat_temp
based on randomization functions as follows:
Time Measurement
22:35:00 0
22:40:00 0
22:45:00 0
22:50:00 0
22:55:00 0
23:00:00 0
23:05:00 0
23:10:00 0.11
23:15:00 0.28
23:20:00 0
23:25:00 0.22
23:30:00 0.08
23:35:00 0.08
23:40:00 0
23:45:00 0.11
23:50:00 0.06
23:55:00 0.23
and then I get the results for
(1). sum = 1.17
(2). n_wet = 8 (measurement > 0)
(3). n_dry = 9 (measurement == 0)
(4). intensity = 0.15
The data in mat_temp
and the corresponding results change every time if I run the script. And I want to run it for 100 times and average the results. I found the possible solution like:
lapply(1:100,function(n)source("my_script.R"))
I tested it with two times and it gave results as follows, where the two values: 2.128558
and 2.160195
are only the results for intensity
. There was not results for the others: sum
, n_wet
and n_dry
> lapply(1:2,function(n)source("my_script.R"))
[[1]]
[[1]]$value
[1] 2.128558
[[1]]$visible
[1] FALSE
[[2]]
[[2]]$value
[1] 2.160195
[[2]]$visible
[1] FALSE
Can you explain why it only gives one result and how can I manage to average the results after I run my script for 100 times?