0

我知道以前有人问过这个问题,答案一直是使用 sink,但我也收到了提示,我不希望这样。有什么方法可以将输出存储到 .txt 文件而不是提示?

info(hdr) 将以下内容打印到控制台:

> info(hdr)
DataFrame with 3 rows and 3 columns
        Number        Type                 Description
   <character> <character>                 <character>
NS           1     Integer Number of Samples With Data
DP           1     Integer                 Total Depth
DB           0        Flag dbSNP membership, build 131

我想将所有 info() 的输出发送到 .txt 文件,这些是我正在使用的命令

sink("info.txt")
info(hdr) 
sink()

info.txt 中写的内容:

> info(hdr) 
DataFrame with 3 rows and 3 columns
        Number        Type                 Description
   <character> <character>                 <character>
NS           1     Integer Number of Samples With Data
DP           1     Integer                 Total Depth
DB           0        Flag dbSNP membership, build 131

> sink()

为什么命令也会出现?无论如何要防止这种情况?

编辑:为清楚起见。函数 info() 来自以下链接的 VariantAnnotation 包:http: //www.bioconductor.org/help/workflows/variants/。的输出str(hdr)是:

Formal class 'VCFHeader' [package "VariantAnnotation"] with 3 slots
  ..@ reference: chr(0) 
  ..@ samples  : chr "GS06985-1100-37-ASM"
  ..@ header   :Formal class 'SimpleDataFrameList' [package "IRanges"] with 4 slots
  .. .. ..@ elementType    : chr "DataFrame"
  .. .. ..@ elementMetadata: NULL
  .. .. ..@ metadata       : list()
  .. .. ..@ listData       :List of 4

更多的行,但我截断了。

4

0 回答 0