I have a code that evaluates parameter values for 4 simultaneous equations. I'm particularly interested to store all the parameter combinations when a + b (stored in results$ab) is greater than 3000. If it is greater than 3000, then it's coded as "Yes". I want to write a for-loop that will loop through the code to check for if a + b > 3000 and store the corresponding values. Then, I want the program to loop 1000 times, and store the parameter values for corresponding "Yes". I am trying to store the output, but it's not yielding me any results.
x <- seq(from = 0.0001, to = 1000, by = 0.1)
t <- seq(from = 0.0001, to = 1000, by = 0.1)
v <- seq(from = 0.0001, to = 1000, by = 0.1)
w <- seq(from = 0.0001, to = 1000, by = 0.1)
n <- seq(from = 0.0001, to = 1000, by = 0.1)
f <- seq(from = 0.0001, to = 1000, by = 0.1)
values <- list(x = x, t = t, v = v, w = w, n = n, f = f)
for(i in 1:1000){
eqs <- list(
a = expression(x * t - 2 * x),
b = expression(v - x^2),
c = expression(x - w*t - t*t),
d = expression((n - f)/t)
)
for(i in 1:1000){
samples <- 10000
values.sampled <- lapply(values, sample, samples)
results[i] <- sapply(eqs, eval, envir = values.sampled)
results[i] <- data.frame(results)
results$ab[i] <- results$a[i] + results$b[i]
results$binary[i] <- ifelse(results$ab[i] > 3000, "Yes","No")
output[i] <- results[results$binary=="Yes",]
}
what <- as.list(output)