Hello, I have been watching my output as I create functions and do other things in r. One thing I don't like is the [1,] type notation at the beginning of a line. I have been able to change that to a number such as 1 2 etc. using as.data.frame(object). How can I stop the printing of a line number and column heading if I want to? I am thinking about publishing and writing of papers. It is much easier to not have to remove that leading line number when inserting output into papers. Thank you. Sincerely, mmstat
xtable in the library xtable does a good job if you are using latex to write up your results. For example:> xtable(matrix(rnorm(20),5,5))% latex table generated in R 2.8.0 by xtable 1.5-4 package % Fri Mar 20 13:48:53 2009 \begin{table}[ht] \begin{center} \begin{tabular}{rrrrrr} \hline & 1 & 2 & 3 & 4 & 5 \\ \hline 1 & -0.45 & 0.25 & -0.42 & -1.64 & -0.45 \\ 2 & 1.39 & 0.06 & 0.08 & 2.12 & 1.39 \\ 3 & 0.49 & -0.78 & -1.28 & -0.45 & 0.49 \\ 4 & -0.11 & -0.81 & 1.48 & 0.30 & -0.11 \\ 5 & 0.12 & -0.11 & -0.14 & 1.50 & 0.12 \\ \hline \end{tabular} \end{center} \end{table} Or you could roll your own using for loops and the print function if this format isn't what you want. HTH, Andrew. On Mar 20, 12:48?pm, "Mary A. Marion" <mms... at comcast.net> wrote:> Hello, > > I have been watching my output as I create functions and do other things > in r. > One thing I don't like is the [1,] type notation at the beginning of a > line. ?I have been > able to change that to a number such as 1 2 etc. ? using > as.data.frame(object). > > How can I stop the printing of a line number and column heading if I > want to? > I am thinking about publishing and writing of papers. ?It is much easier > to not have to > remove that leading line number when inserting output into papers. > > Thank you. > > Sincerely, > mmstat > > ______________________________________________ > R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hi Mary, To print without [1,] use cat() instead of print(). To get rid of the row names when printing a data.frame use: print(data.frame, row.names = FALSE) To get nice Latex tables, you can use xtable (as the other reply suggested). If you want to include it in Word, you can export your data using write.table and read it into Excel to make a table for Word. cheers, Paul Mary A. Marion wrote:> Hello, > > I have been watching my output as I create functions and do other > things in r. > One thing I don't like is the [1,] type notation at the beginning of a > line. I have been > able to change that to a number such as 1 2 etc. using > as.data.frame(object). > > How can I stop the printing of a line number and column heading if I > want to? > I am thinking about publishing and writing of papers. It is much > easier to not have to > remove that leading line number when inserting output into papers. > > Thank you. > > Sincerely, > mmstat > > ______________________________________________ > 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.-- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul