0

My code is:

Normality <- tapply(input$TotalAuthBdNet.USD., input$Country, summary)

The output displayed is:

$Albania
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
0.000e+00 1.066e+04 2.730e+04 3.403e+07 5.015e+04 2.720e+09 

$Angola
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   5405   15323   52522  486451  170000 4513196 

$`Antigua and Barbuda`
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
  22622   22622   22622   22622   22622   22622       2 

$Argentina
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
      0   15814   45000  212800  193626 4080293      15 

Country names are in rows and each country will have such statistic. I want the output as:

Country   Min.        1st Qu.  Median    Mean     3rd Qu.      Max.    NA's 
Albania  0.000e+00 1.066e+04 2.730e+04 3.403e+07 5.015e+04 2.720e+09
Angola      5405   15323   52522  486451  170000 4513196
Argentina      0   15814   45000  212800  193626 4080293      15

The country name is a list identified from the file.

Jaap
  • 81,064
  • 34
  • 182
  • 193
Narayanan
  • 1
  • 1

2 Answers2

1

A simple rbind would do.. E.g.

do.call(rbind, tapply(mpg$year, mpg$model, summary))
erocoar
  • 5,723
  • 3
  • 23
  • 45
0

You can also directly call aggregate so you don't need the extra step:

aggregate(Sepal.Length ~ Species, iris, summary)
#      Species Sepal.Length.Min. Sepal.Length.1st Qu. Sepal.Length.Median Sepal.Length.Mean Sepal.Length.3rd Qu. Sepal.Length.Max.
# 1     setosa             4.300                4.800               5.000             5.006                5.200             5.800
# 2 versicolor             4.900                5.600               5.900             5.936                6.300             7.000
# 3  virginica             4.900                6.225               6.500             6.588                6.900             7.900
moodymudskipper
  • 46,417
  • 11
  • 121
  • 167