vendredi 14 septembre 2018

the ifelse statment is returning error in this nested loop

I ran the below code:

for (i in 1:12) {
  if (i %% 2 ==1) print(i)
  ifelse (i=3,"three",i)}

I want the output to reflect the word three whenever 3 comes in the output.

I get the below error:

Error in ifelse(i = 3, "three", 1:12) : unused argument (i = 3)

Aucun commentaire:

Enregistrer un commentaire