0

I know this has been asked before and the answer has always been to use sink but I'm getting the prompt written out too and I don't want that. Any way to just store the output to a .txt file and not the prompts?

info(hdr) prints the following to console:

> 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

I want to send all of info()'s output to a .txt file and these are the commands I'm using

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

What's written in 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()

Why are the commands showing up too? Anyway to prevent that?

EDIT: for clarity. The function info() comes from VariantAnnotation package from the following link: http://www.bioconductor.org/help/workflows/variants/. The output of str(hdr) is:

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

Many more lines but I truncated.

  • Where is the `info()` function coming from? What type of object id `hdr`? Be sure to include a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) otherwise it's hard to help you. In my experience `sink()` does not work as you are describing it. Doing `sink("test.txt"); head(mtcars); sink()` does not include prompts for me. – MrFlick Jun 30 '16 at 20:30
  • The function comes from packages from Bioconductor.org. This is the original code: http://www.bioconductor.org/help/workflows/variants/ Apologies. Thought I'd keep the problem as concise as possible. From what I understand, its just printing whatever info() does to stdout. And sink did something weird. Didn't know what to make of it – move_slow_break_things Jun 30 '16 at 20:34

0 Answers0