Hello everyone,
I have a dataframe with a certain number of participants, and a column with their age, as well as several other columns with some scores I have measured.
I first would like to report the measured scores of the youngest participants to a new column entitled "score_youngs", and then do the same thing with the oldest participants (basically separate the measured scores of the youngs and the oldest, while keeping the original score column).
I have already created an empty column score_youngs full of NAs, and if the participants are younger than 16, I would like to report their scores from a previous column to the newly created column score_youngs.
Here is the code I have made:
frame$score_youngs <- NA
frame$score_olds <- NA
f <- function(frame, age) {
ifelse(frame$age <= 16.0, frame$score_youngs <- frame$score, NA)
}
When I do this, the result is that it just reported ALL the scores into the score_youngs column, without respecting the condition I put! What is my mistake?
Thank you very much