s-news
[Top] [All Lists]

Re: question with SINK

To: <duo_wan@yahoo.com>, <s-news@lists.biostat.wustl.edu>
Subject: Re: question with SINK
From: <Bill.Venables@csiro.au>
Date: Wed, 7 Feb 2007 09:45:43 +1000
Domainkey-signature: s=email; d=csiro.au; c=nofws; q=dns; b=pBk54o+8P9KusjXpguij67Jv0DGtNagUt5UIOsfOCjDLncVJH4XMSqwvJF9JH0ap9ZVVdMZxs8QUd/nGGZS+NXYaLc9UXlQkHKd/KqyusZfOc3/YspdFAmlsu+gYi+1S;
References: <200770.45454.qm@web36203.mail.mud.yahoo.com>
Thread-index: AcdKGPW9ZpiZJkOXQ1O69OPzzMonzwALbvMA
Thread-topic: [S] question with SINK

[WNV] notes below
 

From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of duo wan
Sent: Wednesday, 7 February 2007 4:02 AM
To: s-news@lists.biostat.wustl.edu
Subject: Re: [S] question with SINK

Hi All,
 
I am having some problem with SINK output. I am using sink to output the following results:
 
  print(paste("# id ", m))
  print(paste(obs[1,1],obs[1,2],obs[1,3],obs[1,4]))
  print(paste(obs[2,1],obs[2,2],obs[2,3],obs[2,4]))
 
and output file looks like this:
 
[1] 2119
[1] 5
[1] "# id  1"
[1] "C G G C"
[1] "C G T C"
[1] "# id  2"
[1] "C G G C"
[1] "C G T T"
[1] "# id  3"
[1] "C G G C"
[1] "C G T T"
[1] "# id  4"
[1] "C G T C"
[1] "C G T T"
 
Is there any way to
 
1. remove [1]
[WNV] use cat(...) instead of print(...) 
2. remove " "-quote
[WNV] use cat(...) instead of print(...) 
3. compress C G T C -> CGTC?
[WNV] use paste with a null separator. 
 
You probably want something like this below, which is a little test demo:

obs <- matrix(c("C", "G", "G", "C",
                  "C", "G", "T", "C"), ncol = 4, byrow = T)
m <- 1
 
sink("test.txt")
cat("#id", m, "\n")
cat(paste(obs[1, ], collapse = ""), "\n")
cat(paste(obs[2, ], collapse = ""), "\n")
sink()
 
 
Your suggestions will be really appreciated.
 
Vincent


Don't get soaked. Take a quick peak at the forecast
with theYahoo! Search weather shortcut.
<Prev in Thread] Current Thread [Next in Thread>