Re: [S] how to remove the display of row-numbers of a data.frame

Alan Zaslavsky (zaslavsk@hcp.med.harvard.edu)
Thu, 2 Apr 1998 07:07:00 -0500 (EST)


> From: Ming Ji <mji@wald.ucdavis.edu>
>
> ... Usually, if you type the name of a
> data.frame, say, xxx.df, then its content will be printed on the screen,
> together with the row-numbers. ...
>
> My question is: is there a way to hide this numbering of the rows of
> xxx.df ...

There is a trick for this for ordinary matrices, which is to assign empty
character data to the row names. You can't do this directly with data frames
because data frames are checked for unique row names. If you look at the
code for print.data.frame you will see that the work is done by the following
line:

print(as.matrix(x), ..., quote = quote, right = right)

so if you have a data.frame X, you can print without row names as follows:

Xmat_as.matrix(x)
dimnames(Xmat)[[1]]_character(nrow(Xmat))
print(as.matrix(Xmat), quote = F, right = T)

Giving, for example, the following output:

a b cc
1 11 a
2 12 b
3 13 c

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news