[R] Fw: Re: Is there anything like a write.fwf() or possibility to print adata.frame without rownames?

Petr Pikal petr.pikal at precheza.cz
Tue Nov 22 13:08:52 CET 2005


   Hi

   can you please explain why do you need it? What do you want to do with
   the exported file?

   I wonder what type of software can not accept any reasonable delimiter
   and requires fwf files.

   The  only  workaround  I  can  imagine  is  to transfer all columns to
   character  and  add  leading spaces to each item which is shorter than
   longest  item  in  specified column to equalize length of all items in
   column and then use

   write.table( tab, "file.txt", sep=" ", row.names=F)

   as suggested.

   But I still wonder why?

   If you used e.g.

   write.table( tab, "file.xls", sep="\t", row.names=F)

   you can open it directly by spreadsheet program just by clickung on it
   and everything shall be properly aligned.

   HTH

   Petr

   On 22 Nov 2005 at 12:26, Gorjanc Gregor wrote:

   Date sent:                Tue, 22 Nov 2005 12:26:43 +0100

   From:                       "Gorjanc Gregor"
   <Gregor.Gorjanc at bfro.uni-lj.si>

   To:                           <r-help at stat.math.ethz.ch>

   Copies to:                042045003 at fudan.edu.cn

   Subject:                     [R]  Fw:  Re:  Is  there  anything like a
   write.fwf() or possibility to

                                    print adata.frame without rownames?

   > >>Petr Pikal wrote:

   > >>> Hi

   > >>>

   > >>> did you tried something like

   > >>>

   > >>> write.table( tab, "file.txt", sep="\t", row.names=F)

   > >>>

   > >>> which writes to tab separated file?

   > >>>

   > >>

   > >>Petr thanks, but I do not want a tab delimited file. I need spaces

   > >>between columns.

   > >

   > > write.table( tab, "file.txt", sep="", row.names=F)

   > > Can it do what you want?

   >

   > Ronggui thanks,

   >

   > but this does not work also. For example I get something like

   > this bellow

   >

   > "26" "1" 42 "DA" "DA" "lipa" "Monika"

   > "26" "1" 42 "DA" "DA" "lipa" "Monika"

   > "27" "1" 41 "DA" "DA" "smreka" "Monika"

   > "27" "1" 41 "DA" "DA" "smreka" "Monika"

   >

   > and you can see, that there is a problem, when all "values"

   > in a column do not have the same length. I need to get

   >

   > "26" "1" 42 "DA" "DA" "lipa"   "Monika"

   > "26" "1" 42 "DA" "DA" "lipa"   "Monika"

   > "27" "1" 41 "DA" "DA" "smreka" "Monika"

   > "27" "1" 41 "DA" "DA" "smreka" "Monika"

   >

   > i.e. columns should be properly aligned.

   >

   > Lep pozdrav / With regards,

   >     Gregor Gorjanc

   >

   >
   ----------------------------------------------------------------------

   > University of Ljubljana Biotechnical Faculty        URI:

   >    http://www.bfro.uni-lj.si/MR/ggorjan    Zootechnical   Department
   mail:

   > gregor.gorjanc <at> bfro.uni-lj.si Groblje 3                   tel:

   > +386 (0)1 72 17 861 SI-1230 Domzale             fax: +386 (0)1 72 17

   > 888 Slovenia, Europe

   >
   ----------------------------------------------------------------------

   >  "One  must  learn by doing the thing; for though you think you know
   it,

   >  you have no certainty until you try." Sophocles ~ 450 B.C.

   >

   > ______________________________________________

   > R-help at stat.math.ethz.ch mailing list

   > https://stat.ethz.ch/mailman/listinfo/r-help

   > PLEASE do read the posting guide!

   > http://www.R-project.org/posting-guide.html

   Petr Pikal

   petr.pikal at precheza.cz



More information about the R-help mailing list