cbind converting factor to numeric

纵然是瞬间 提交于 2019-12-01 18:35:21

We are cbinding vectors and the output will be a matrix. The matrix can hold only a single class. So, if there is any vector that is non-numeric, it will convert the whole matrix to 'character' and as the first column is already a factor, we get the numeric levels of that factor. Better would be to use data.frame

data.frame(Event=df2$EVTYPE,Total = df2$TOTAL_INJURIES,Severity="INJURE")

Or we can use bind_cols or data_frame from dplyr

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