1
I have a problem, and I can’t fix it. I am creating a function and at a certain point use ifs and Else. In function x argument : develop <- Function(x, temp, date) I will leave the option for the user to put 5 strings. So I did the if and Else If you put one, the function will do a certain thing and so on. My problem is that it is only working in the first string option I put. In others it says that the object was not found.
calb <- "calb"
if (x == calb & temp == 25){
cat("O valor de p é:", tabela.calb25[[1]]$"Pr(>F)"[1])
x11()
boxplot(Peso ~ Idade + Substrato , data = dados.calb25)
} else if (x == calb & temp == 30){
cat("O valor de p é:", tabela.calb30[[1]]$"Pr(>F)"[1])
x11()
boxplot(Peso ~ Idade + Substrato , data = dados.calb30)
} else if (x == calb & temp == 35){
cat("O valor de p é:", tabela.calb35[[1]]$"Pr(>F)"[1])
x11()
boxplot(Peso ~ Idade + Substrato , data = dados.calb35)
}else if (x == cmeg & temp == 25){
cat("O valor de p é:", tabela.cmeg25[[1]]$"Pr(>F)"[1])
x11()
boxplot(Peso ~ Idade + Substrato , data = dados.cmeg25)
And so it goes until I finish the 5 options. In this case it works the first (calb) and for example, cmeg already than the object was not found. I already tried to put the x == "cmeg"
but to no avail.
Can someone help me ?
This example is not reproducible.
– Flavio Barros
@Noobsaibot I was careful, the code does exactly the same as the previous one. The AP problem is in the variable
cmeg
, not usx11/boxplot
. I think it’s better to simplify so we can focus on the problem and not on confusing code. But okay, no problem.– Rui Barradas
@Noobsaibot OK, I’ll answer.
– Rui Barradas