I've this DF containing 3 variables:
# Generate df
set.seed(101)
df <- data.frame("phd" = sample(c("yes", "no"), 100, replace = TRUE),
"age" = sample(c(23:45), 100, replace = TRUE),
"gre" = sample(c(130:170), 100, replace = TRUE))
I need to compute the following algorithm:
I proposed this (uncomplete) code:
# IF cycle
if (df$phd == "no") {
df$phd.status = ifelse(df$gre <151, "No PhD low score", ifelse(df$gre >151, "No PhD high score")
} else (df$phd == "yes") {
df$phd.status = ifelse(df$age <30, ifelse(df$gre <151, "PhD 30yr low score"))
}
I'm getting troubles in writing this code. I'm referring to several posts
Aucun commentaire:
Enregistrer un commentaire