I'm fairly new to R and was hoping to get some help on an issue I'm having.
I want to for loop through an input column with numeric values, and depending on whether those values are greater/less than a given value, I want it to output "above cutoff", "below cutoff" or "borderline". I specifically want the output to be in a new column, outputColumn, and in the corresponding row of the input value.
Here is what I have tried so far:
for (i in inputColumn) {
if (i <= 5)
data$outputColumn <- "BelowCutoff"
if (i >= 20)
data$outputColumn <- "AboveCutOff"
else
data$outputColumn <- "Borderline"
}
When I execute this for loop, a new column is made called "outputColumn", but every single row in the column says "borderline", which isn't correct. My inputColumn has rows with values above 20 and values 5, so I am expecting to get some rows that say "belowcutoff" or "abovecutoff".
I appreciate any input and help!