R: ifelse function returns vector position instead of value (string)

后端 未结 3 749
没有蜡笔的小新
没有蜡笔的小新 2020-12-16 17:26

I have a very strange problem concerning the ifelse function: it does not return a factor (as I want) but something like the position of the factor.

The dataset I u

3条回答
  •  旧时难觅i
    2020-12-16 18:08

    The field answer is factor, hence your function returns number (level of factor).

    What you need to do is:

    aDDs$answer <- as.character(aDDs$answer)
    

    and then it works.

提交回复
热议问题