Hi,
Thanks to Prof.Ripley (reply cced to list) and Thomas Hotz (reply below) for
their help on this problem.
Regards,
Glenn
-----Original Message-----
From: Hotz, T. [mailto:th50@leicester.ac.uk]
Sent: 15 May 2003 10:44
To: Glenn.Treacy@ILIM.COM
Subject: RE: [S] Query: output of write.table
Dear Glenn,
Probably I would go for sinking the output in the desired file, change the
line width, and print; like
printInFile<-function(mydata,file,n){
sink(file)
oldWidth<-options()$width
options(width=n)
print(mydata)
options(width=oldWidth)
sink()
}
x<-data.frame(aaa=c(T,F),b=c("x","yyy"),c=c(1,100.1))
printInFile(x,"clipboard",20)
aaa b c
1 T x 1.0
2 F yyy 100.1
Hope that helps.
Best wishes
Thomas
---
Thomas Hotz
Research Associate in Medical Statistics
University of Leicester
United Kingdom
Department of Epidemiology and Public Health
22-28 Princess Road West
Leicester
LE1 6TP
Tel +44 116 252-5410
Fax +44 116 252-5423
Division of Medicine for the Elderly
Department of Medicine
The Glenfield Hospital
Leicester
LE3 9QP
Tel +44 116 256-3643
Fax +44 116 232-2976
-----Original Message-----
From: Glenn.Treacy@ILIM.COM [mailto:Glenn.Treacy@ILIM.COM]
Sent: 15 May 2003 10:12
To: s-news@lists.biostat.wustl.edu
Subject: [S] Query: output of write.table
Hi,
I am using S+6.1 on WinNT4.
I have the following quite trivial problem with the presentation of the
output write.table.
I use write.table to generate a log file by writing out dataframes I am
interested in to a text file. Some of the dataframes have a small number of
rows but a large number of columns many of which are logical in type.
Essentially the data and column names are not formatted consistently which
makes it difficult to ascribe a particular data item to a column in the
output.
I get output like the following
Row.names ColA ColB ColC ColD
2 T T T F
4 T F T F
5 F F F T
but would prefer
Row.names ColA ColB ColC ColD
2 T T T F
4 T F T F
5 F F F T
Before I attempt to solve this problem, by converting everything to
character and calculating numbers of leading spaces to paste to items to
clena the output, I just wanted to check whether there was a more
straightforward solution?
Regards,
Glenn
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept
for the presence of computer viruses.
**********************************************************************
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|