Re: [R] could i change the ouput style on summary?

From: Jim Lemon <>
Date: Thu 06 Jul 2006 - 11:03:46 EST

Hi Zhi Jie,

I had a look at the summary function, and a minor extension seems to do what you want.

is.numeric.factor<-function(x) {

   if(is.factor(x)) {
    if(any( return(FALSE)     return(TRUE)

summary.table<-function(x) {
  num.index<-which(sapply(x,is.numeric))   fac.index<-which(sapply(x,is.numeric.factor))

  cat("Summary table for",deparse(substitute(x)),"\n")
  cat("             Min.  1st Qu.   Median     Mean  3rd Qu.

  if(length(num.index)) {
   for(i in 1:length(num.index))

cat(formatC(c(varnames[num.index[i]],as.numeric(summary(x[[num.index[i]]]))),width=8),"\n")   }
  if(length(fac.index)) {
   for(i in 1:length(fac.index))

cat(formatC(c(varnames[fac.index[i]],as.numeric(summary(x[[fac.index[i]]]))),width=8),"\n")   }

However, I got interested in the problem in an unoccupied moment and wrote a set of functions named "describe" that may be an even more suitable solution to your problem. Let me know if you would like to try them.

Jim mailing list PLEASE do read the posting guide! Received on Wed Jul 05 21:12:26 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 05 Jul 2006 - 22:16:23 EST.

Mailing list information is available at Please read the posting guide before posting to the list.