【发布时间】:2015-02-16 04:43:54
【问题描述】:
我有一个data.frame,其类列是Factor。我想将其转换为数字,以便我可以使用相关矩阵。
> str(breast)
'data.frame': 699 obs. of 10 variables:
....
$ class : Factor w/ 2 levels "2","4": 1 1 1 1 1 2 1 1 1 1 ...
> table(breast$class)
2 4
458 241
> cor(breast)
Error in cor(breast) : 'x' must be numeric
如何将因子列转换为数值列?
【问题讨论】:
-
这个问题出现得太频繁了,以至于不在 SO 上是重复的
-
最好的答案总是一样的,“阅读
?factor”
标签: r