Inside of my learnr tutorial, I'm getting warnings whenever I use else if
. See below (lines 6, 8, 10):
Here is the code for the exercise and its solution
{r KC2, exercise=TRUE, exercise.lines=15}
# YOUR WORK HERE
# Subtract 85 from 100 and assign the result to an object named `score`
# If score is 90 or above, assign 'A' to an object named `grade`
# Otherwise if the `score` is 80 or above, assign 'B' to an object named `grade`
# Otherwise if the `score` is 70 or above, assign 'C' to an object named `grade`
# Otherwise if the `score` is 60 or above, assign 'D' to an object named `grade`
# Otherwise if the `score` is below 60, assign 'Hidden' to an object named `grade`
# Print the value stored in `grade`
{r KC2-solution}
# Subtract 85 from 100 and assign the result to an object named `score`
score = 100 - 85
if (score >= 90){ # If score is 90 or above, assign "A" to an object named `grade`
grade <- "A"
} else if (score >= 80){ # Otherwise if the `score` is 80 or above, assign "B" to an object named `grade`
grade <- "B"
} else if (score >= 70){ # Otherwise if the `score` is 70 or above, assign "C" to an object named `grade`
grade <- "C"
} else if (score >= 60){ # Otherwise if the `score` is 60 or above, assign "D" to an object named `grade`
grade <- "D"
} else{ # Otherwise if the `score` is below 60, assign "Hidden" to an object named `grade`
grade <- Hidden
}
# Print the value stored in `grade`
print(grade)
Does anyone know why this is happening?