Hi, and welcome!
Just for reference (you've got the basic ideas), see reproducible example, called a reprex and homework policy.
Assignment
is an important part of the error message; it's either an explicit assignment such as
Ka1 <- 10^(-6.52)
Ka2 <- 10^(-10.56)
Kw <- 10^(-14.704)
Kso <- 10^(-8.09)
Kh <- 10^(-1.2)
Pco2 <- 10^(-3.5)
H.low <- 0
H.high <- Kw
H.int <- 0.001
(It's also possible to assign with the =
operator, but good style encourages <-
for creating objects and =
for creating attributes in objects.)
or an implicit assignment in a function.
Your code has two functions -- the for
loop and solve.default()
.
Let's look at for
first. (BTW: take a look at purrr:map()
which is tidier, a term you will grow to know and love here.)
What does for
do? Well, for one thing, it creates an object OH
. What is its value?
OH
[1] Inf
Uh, oh. Even without getting into solve.default
, it's easy to see that passing Inf
as an argument to any function might be a problem.
So, where does Inf
come from. Hint
> seq(H.low,H.high,H.int)
[1] 0