[R] how to print a data.frame without row.names

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Aug 2 19:19:53 CEST 2005


Martin Maechler <maechler at stat.math.ethz.ch> writes:

> >>>>> "Heinz" == Heinz Tuechler <tuechler at gmx.at>
> >>>>>     on Tue, 02 Aug 2005 17:46:07 +0200 writes:
> 
>   .......................
> 
>     Heinz> I tried this, but then the column headers and column
>     Heinz> contents are not aligned.
> 
>   ........................
> 
> Use the tabulator if you need them aligned :
> 
> write.table(USArrests, row.names = FALSE, sep = "\t")

Unless a column or a header is 8 chars or wider (and UrbanPop is!).

This seems to do it:

  x <- as.matrix(format(USArrests))
  rownames(x) <- rep("", nrow(x))
  print(x, quote=FALSE, right=TRUE)

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907




More information about the R-help mailing list