R学习笔记1

 

1####read.table 读文件报错:
> gse14407<- read.table(file = "GSE14407.ID_REF.txt",sep = "",quote="");head(gse14407) Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 54677 did not have 25 elements

加个选项就不会了 blank.lines.skip=F

 gse14407<- read.table(file = "GSE14407.ID_REF.txt",blank.lines.skip = F,sep = "",quote="\t");head(gse14407)
           V1          V2          V3          V4          V5          V6          V7          V8          V9         V10         V11         V12         V13         V14
1    "ID_REF" "GSM359972" "GSM359973" "GSM359974" "GSM359975" "GSM359976" "GSM359977" "GSM359978" "GSM359979" "GSM359980" "GSM359981" "GSM359982" "GSM359983" "GSM359984"
2 "1007_s_at"     3971.69     1960.09     2783.37     2159.57     1606.38     3678.11     1477.52      2278.2     1020.31     1941.45     1569.94     2207.03     7627.08
3   "1053_at"      318.88     199.035     324.774     299.358     155.957     279.881     100.574      234.04     149.272     95.4396     126.151     225.886     390.509
4    "117_at"     29.9351     125.046     147.306      97.915     41.6004     207.377     21.9873     159.743     64.3492     61.5415     730.459     39.1713     20.1453
5    "121_at"     747.052     775.955     1083.99     977.232     641.556     1236.34     508.222     1278.48     528.405     3140.68        1358     5372.87     7491.51
6 "1255_g_at"     12.9366     29.4865     59.3691     18.9382     10.9505     36.1149     15.9366     40.6492     6.41202     20.1139     7.79616     7.64554     139.951

 

2#####列标签被加 X.

一般要尽量避免行或列名字以数字开头,会给后续分析带来匹配问题;另外名字中出现的非字母、数字、下划线、点的字符都会被转为点,也需要注意,尽量只用字母、下划线和数字。 

解决办法读入时,增加一个参数 `check.names=F`也可以解决问题。 

 gse14407<- read.table(file = "GSE14407.ID_REF.txt",header = T ,blank.lines.skip = F,sep = "\t",quote="",row.names = 1,check.names = F);head(gse14407)
            "GSM359972" "GSM359973" "GSM359974" "GSM359975" "GSM359976" "GSM359977" "GSM359978" "GSM359979" "GSM359980" "GSM359981" "GSM359982" "GSM359983" "GSM359984" "GSM360039"
"1007_s_at"   3971.6900   1960.0900   2783.3700   2159.5700   1606.3800   3678.1100   1477.5200   2278.2000  1020.31000   1941.4500  1569.94000  2207.03000   7627.0800    4582.940
"1053_at"      318.8800    199.0350    324.7740    299.3580    155.9570    279.8810    100.5740    234.0400   149.27200     95.4396   126.15100   225.88600    390.5090     108.685
"117_at"        29.9351    125.0460    147.3060     97.9150     41.6004    207.3770     21.9873    159.7430    64.34920     61.5415   730.45900    39.17130     20.1453     117.919
"121_at"       747.0520    775.9550   1083.9900    977.2320    641.5560   1236.3400    508.2220   1278.4800   528.40500   3140.6800  1358.00000  5372.87000   7491.5100    4057.420
"1255_g_at"     12.9366     29.4865     59.3691     18.9382     10.9505     36.1149     15.9366     40.6492     6.41202     20.1139     7.79616     7.64554    139.9510     126.423
"1294_at"      353.9610    252.8960    230.7590    162.7520    160.5220    252.3190    133.1840    205.4740    79.15250    367.5770   164.90200   499.74300   1099.6000     537.324

  

 

posted @ 2018-06-05 12:46  Yellow_huang  阅读(375)  评论(0编辑  收藏  举报