lundi 21 décembre 2020

R, ifelse error: invalid argument to unary operator

I am using the newest version of R ( I am new to R, just got it last week, learning to plot graphs with it).

My code:

df$bins <- ifelse(df$ROW_A <= 0.1, "0-0.1",

  • ifelse(df$ROW_A <= 0.5, "0.1-0.5",
  • ifelse(df$ROW_A<=1, "0.5-1",
  • ifelse(df$ROW_A <= 2, "1-2",
  • ifelse(df$ROW_A <=5, "2-5",
  • ifelse(df$ROW_A <=10, "5-10",
  • ifelse(df$ROW_A >10, ">10","NA")))))))

I kept getting an error:

Error in +ifelse(df$ROW_A > 10, ">10", "NA") : invalid argument to unary operator

Can anyone kindly advise me what went wrong please?

Aucun commentaire:

Enregistrer un commentaire