Say I have a simple data frame like this in R:
Col1 <- 1:10
Col2 <- 15:6
df <- data.frame(Col1, Col2)
Now I would like to add a text string in a new column that says something about the number in each of those two columns.
df$Eval = "Evaluation:"
When the number in Col1 is >5, I would like to append a text string " Col1) This number is high." to the existing string "Evaluation:". When the number in Col1 is <5, I would like to append " Col1) This number is low." instead. And similarly I would like to append a text string about the number in Col2.
Schematically:
df[df$Col1 >5,]$Eval = " Col1) This number is high."
df[df$Col1 <5,]$Eval = " Col1) This number is low."
df[df$Col2 >9,]$Eval = " Col2) This number is high."
df[df$Col2 <9,]$Eval = " Col2) This number is low."
In the end, the first cell in the column Eval should end up having a text string Evaluation: Col1) This number is low. Col2) This number is high.
How can I achieve this? I've tried to use paste(), but to no avail.