如何在不更改数据框元素的情况下将字符转换为数字?

时间:2017-06-16 05:56:53

标签: r matrix character numeric

有字符矩阵以及我如何在R中转换为数字?    我使用几个代码,如:as.numeric(as.character(df)); lapply(df,as.numeric); sapply(df,as.numeric);但没有获得优势!

  df[1:5,1:10]
       id          G_r78   G_09   G_r805  G_800
 1    "02000H1"    NA      "1"    "2"       "1"
 2    "02000H15"   NA      "0"    "1"       "2" 
 3    "02003H10"   NA      "1"    "1"       "1"
 4    "02003KH8"   NA      "0"    "1"       "1" 

0 个答案:

没有答案