I have a problem and I can not resolve it. I am creating a function and at some point use if s and else . In the x argument of the function: develop < - function (x, temp, date) I will leave the option for the user to put 5 strings. So I did the if and else in case I put one, the function will do certain thing and so on. My problem is that it's only working on the first string option I put. In the 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 the first works (calb) and for example, the cmeg already of that the object was not found. I already tried to put x == "cmeg"
but without success.
Can anyone help me?