Skip to content
Prev 106182 / 398506 Next

Nicely formatted tables

steve wrote:
Hmm, no. Not without further ado. The function summary.data.frame 
produces a table with character entries like "Min. : 1.00 ".

To do better, you first have to note that it can only possibly work for 
purely numeric data frames. If you have one of those, then you might 
base something off sapply(X, summary), except that it won't work if only 
some columns have NA's. Here's an idea:
c(s,"NA's"=0) else s}
Ozone Solar.R   Wind  Temp Month  Day
Min.      1.00     7.0  1.700 56.00 5.000  1.0
1st Qu.  18.00   115.8  7.400 72.00 6.000  8.0
Median   31.50   205.0  9.700 79.00 7.000 16.0
Mean     42.13   185.9  9.958 77.88 6.993 15.8
3rd Qu.  63.25   258.8 11.500 85.00 8.000 23.0
Max.    168.00   334.0 20.700 97.00 9.000 31.0
NA's     37.00     7.0  0.000  0.00 0.000  0.0

However, there's an issue with the NA count getting displayed to
three decimal places...