R中将字符型数字转为字符串(2018-06-06)

1 处理R数据时,出现如下报错:

 > mydata<-read.csv("Transcript_RPKM.csv")
  > summary("YSH-mRNA-1","YSH-mRNA-2")
    Length     Class      Mode 
        1 character character 
  > nucmydata<-apply(mydata,2,as.numeric)
   Warning message
   In apply(mydata, 2, as.numeric) : 强制改变过程中产生了NA
  > summary("YSH-mRNA-1","YSH-mRNA-2")
      Length     Class      Mode 
        1 character character  

2 查找原因:
https://blog.csdn.net/lili_wuwu/article/details/51847809
数据是字符形式,而低级的字符不能转为高阶的数值,只能先转为因子。
根据这个也没有解决

> mydata<-factor("Transcript_RPKM.csv")
> class(mydata) 
[1] "factor"
> as.numeric(mydata)
[1] 1
> as.character(mydata)
[1] "Transcript_RPKM.csv"
> as.numeric(as.character(mydata))
[1] NA
Warning message:
强制改变过程中产生了NA 

https://www.cnblogs.com/jiangshuping/p/5435526.html

> getwd()
[1] "/home/andengdi/lyr/rna-seq"
> madata=read.table("Transcript_RPKM.csv")
> mydata=read.table("Transcript_RPKM.csv")
> mydata=as.matrix(mydata)
> mydata=apply(mydata,2,as.numeric)
Warning message:
In apply(mydata, 2, as.numeric) : 强制改变过程中产生了NA

在换方法.......

你可能感兴趣的:(R中将字符型数字转为字符串(2018-06-06))