Warning when defining factor: duplicated levels in factors are deprecated

做~自己de王妃 提交于 2019-11-28 09:08:58

Yes, almost all of that is irrelevant to your problem.

You are trying to create a factor with the following levels: rev(dataset$variable). That yields:

[1] C3 C3 C3 C3 C2 C2 C2 C2 C1 C1 C1

See how you have replicated levels? You'll want to have each level only once, in the order that you want. The default is sort(unique(dataset$variable)), which gives C1 C2 C3, or you could use rev(unique(dataset$variable) to give C3 C2 C1.

The forcats package has several convenience functions to easily make or change factors and the order of their levels.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!