1)R语言读取excel文件时,出现Error in make.names(vnames, unique = TRUE) : invalid multibyte string 3
eg:
data = read.xlsx(“C:\Users\vv\Desktop\test.xlsx”)
Error in make.names(vnames, unique = TRUE) : invalid multibyte string 3
只要在最后加上encoding = "UTF-8"就行了
data = read.xlsx(“C:\Users\vv\Desktop\test.xlsx”,encoding = “UTF-8”)
2)R语言字符型矩阵转换成数值型矩阵
不能用as.numeric,因为变成向量了,不再是矩阵!!!!!
可以用as.numeric
假设你的矩阵是a
b=matrix(as.numeric(a),nrow=nrow(a))