Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 将TAPLY汇总结果转换为数据框_R - Fatal编程技术网

R 将TAPLY汇总结果转换为数据框

R 将TAPLY汇总结果转换为数据框,r,R,我的代码是: Normality <- tapply(input$TotalAuthBdNet.USD., input$Country, summary) 国家名称按行排列,每个国家都有这样的统计数据。我希望输出为: 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

我的代码是:

Normality <- tapply(input$TotalAuthBdNet.USD., input$Country, summary)
国家名称按行排列,每个国家都有这样的统计数据。我希望输出为:

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

国家名称是从文件中识别的列表。

一个简单的
rbind
就可以了。。例如

do.call(rbind, tapply(mpg$year, mpg$model, summary))

您也可以直接调用
aggregate
,因此不需要额外的步骤:

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
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