如何将以字符表示的分类变量转换为R中的数字分类变量?

时间:2017-04-18 21:04:52

标签: r variables replace numbers categorical-data

我试图将我的分类变量转换为数字(我想用数字替换这些单词,而不是一个一个地指定它们并指定它们应该具有的数字):

abaz
 [1] " Crime"       " Animation"   " Drama"       " Comedy"      " Adventure"  

 [6] " Biography"   " Documentary" "character(0)" " Thriller"    " Fantasy"    

[11] " Action"     

> apply(abaz, 1, function(x) match(x, letters))

我收到此错误:

Error in apply(abaz, 1, function(x) match(x, letters)) : 
  dim(X) must have a positive length

0 个答案:

没有答案