[R] hide row and column-names in cat()

Dimitris Rizopoulos d.rizopoulos at erasmusmc.nl
Wed Aug 24 14:19:45 CEST 2011


try function write.matrix() from package MASS, e.g.,

library(MASS)
write.matrix(my.df)


I hope it helps.

Best,
Dimitris


On 8/24/2011 1:46 PM, Tim Haering wrote:
> Dear list,
>
> to prepare data as input for a stand-alone groundwater model I use the
> cat() function to print data.
> I want to print a table with print() or cat() but without the row- and
> column-names. Is this possible?
>
> Here a small example
>
> my.df<- rbind(c("Nr","FraSand","FraSilt","FraClay","pH"), c("",
> "(kg.kg-1)","(kg.kg-1)", "(kg.kg-1)", "(-)"), c(1, 19, 60, 21, 7.1),
> c(2, 35, 53, 11, 7.7))
> print(my.df, quote=FALSE)
>       [,1] [,2]      [,3]      [,4]      [,5]
> [1,] Nr   FraSand   FraSilt   FraClay   pH
> [2,]      (kg.kg-1) (kg.kg-1) (kg.kg-1) (-)
> [3,] 1    19        60        21        7.1
> [4,] 2    35        53        11        7.7
>
> What I want to have is this:
>
>   Nr   FraSand   FraSilt   FraClay   pH
>        (kg.kg-1) (kg.kg-1) (kg.kg-1) (-)
>   1    19        60        21        7.1
>   2    35        53        11        7.7
>
> Thank you.
> TIM
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/



More information about the R-help mailing list