如何在R中使read.table()忽略“#”

时间:2014-01-30 08:07:23

标签: r read.table

如果我试试这个:

read.table("IntervalBasedReport (10).xls",dec=",",skip=20,fill=NA,sep="\t")

我得到了(V6的标题是“#probes”而其余部分未读入(我认为)):

                                   V1    V2       V3          V4
1                        AberrationNo   Chr Cytoband       Start
2     US11113888_253174610065_S01_2_2                           
3                                   1  chr1   p36.13  16,348,612
4                                   2  chr2    q37.3 242,856,588
5                                   3  chr8    p11.1  43,371,449
6                                   4 chr14    q32.2 101,291,239
7                                   5  chrX   p11.23  48,323,343
8                                   6  chrX   p11.22  53,449,448
9         Number of calls per sample:                           
10 US11113888_253174610065_S01_2_2 =6                           
            V5  V6       V7        V8        V9
1         Stop  NA                             
2               NA                             
3   16,383,299  29 0.407738  0.000000 3.601e-22
4  243,007,359  29 0.000000 -0.793036 2.729e-77
5   43,381,512   4 0.755647  0.000000 1.770e-11
6  101,295,092  23 0.318718  0.000000 1.131e-11
7   48,760,198 121 0.250196  0.000000 7.654e-14
8   53,459,171  18 0.429467  0.000000 3.202e-10
9               NA                             
10              NA                             
                                                                                                                 V10
1                                                                                                                   
2                                                                                                                   
3                                                                                                     CLCNKA, CLCNKB
4                                                                                                                   
5                                                                                                                   
6                                                                                                               MEG3
7  SLC38A5, FTSJ1, PORCN, EBP, TBC1D25, RBM3, WDR13, WAS, SUV39H1, GLOD5, GATA1, HDAC6, ERAS, PCSK1N, TIMM17B, PQBP1
8                                                                                             SMC1A, RIBC1, HSD17B10
9                                                                                                                   
10     

实际问题是如果我尝试通过执行以下操作跳过第二行而得到的错误:

read.table(file="IntervalBasedReport (10).xls",dec=",",skip=22,fill=NA,sep="\t",col.names=read.table("IntervalBasedReport (10).xls",skip=20,nrows=1,dec=",",sep="\t"))
Error in read.table(file = "IntervalBasedReport (10).xls", dec = ",",  : 
  more columns than column names 

Collumns V7和on有标题,我想使用它。 非常感谢你!

0 个答案:

没有答案