Reputation: 25
i created this table.
dat <- matrix(rbinom(6*100, 6, 0.5), ncol=6)
then use one row from at the table to fill the 'size' statement to train the model.
nn.sizes <- dat[1,]
sample.number <- length(dat2[[1]][,1])
nns <- lapply(1:length(dat2), function(i){nn <- nnet(dat2[[i]][1:(sample.number),], dat3[[i]][(twindow+1):(length(dat3[[i]]))],size=nn.sizes[i], linout = TRUE)})
my question is, i only know how to do it manually one by one, it means i have to run 100 times. Is there a way to run it once
Upvotes: 1
Views: 93
Reputation: 99351
You could use replicate()
and only create a single vector on each replication, instead of looping over a matrix. This just loops the expression block (code between the {}
braces), evaluating it 100 times.
replicate(100, {
nn.sizes <- rbinom(6, 6, 0.5)
<the rest of your code here>
})
Upvotes: 2