另一种选择是包中的Desc
函数,DescTools
它可以生成汇总统计数据和图表。
library(DescTools)
Desc(iris3, plotit = TRUE)
#> -------------------------------------------------------------------------
#> iris3 (numeric)
#>
#> length n NAs unique 0s mean meanCI
#> 600 600 0 74 0 3.46 3.31
#> 100.0% 0.0% 0.0% 3.62
#>
#> .05 .10 .25 median .75 .90 .95
#> 0.20 1.10 1.70 3.20 5.10 6.20 6.70
#>
#> range sd vcoef mad IQR skew kurt
#> 7.80 1.98 0.57 2.52 3.40 0.13 -1.05
#>
#> lowest : 0.1 (5), 0.2 (29), 0.3 (7), 0.4 (7), 0.5
#> highest: 7.3, 7.4, 7.6, 7.7 (4), 7.9
结果Desc
可以重定向到 Microsoft Word 文件
### RDCOMClient package is needed
install.packages("RDCOMClient", repos = "http://www.omegahat.net/R")
# or
devtools::install_github("omegahat/RDCOMClient")
# create a new word instance and insert title and contents
wrd <- GetNewWrd(header = TRUE)
DescTools::Desc(iris3, plotit = TRUE, wrd = wrd)
skim
来自skimr包的功能也不错
library(skimr)
skim(iris)
Skim summary statistics
n obs: 150
n variables: 5
-- Variable type:factor --------------------------------------------------------
variable missing complete n n_unique
Species 0 150 150 3
top_counts ordered
set: 50, ver: 50, vir: 50, NA: 0 FALSE
-- Variable type:numeric -------------------------------------------------------
variable missing complete n mean sd p0 p25 p50
Petal.Length 0 150 150 3.76 1.77 1 1.6 4.35
Petal.Width 0 150 150 1.2 0.76 0.1 0.3 1.3
Sepal.Length 0 150 150 5.84 0.83 4.3 5.1 5.8
Sepal.Width 0 150 150 3.06 0.44 2 2.8 3
p75 p100 hist
5.1 6.9 ▇▁▁▂▅▅▃▁
1.8 2.5 ▇▁▁▅▃▃▂▂
6.4 7.9 ▂▇▅▇▆▅▂▂
3.3 4.4 ▁▂▅▇▃▂▁▁
编辑:可能偏离主题,但值得一提的DataExplorer
是探索性数据分析包。
library(DataExplorer)
introduce(iris)
#> rows columns discrete_columns continuous_columns all_missing_columns
#> 1 150 5 1 4 0
#> total_missing_values total_observations memory_usage
#> 1 0 750 7256
plot_missing(iris)
plot_boxplot(iris, by = 'Species')
plot_histogram(iris)
plot_correlation(iris, cor_args = list("use" = "pairwise.complete.obs"))
编辑2: ExPanDaR
很酷
install.packages("ExPanDaR")
# devtools::install_github("joachim-gassen/ExPanDaR")
library(ExPanDaR)
library(gapminder)
ExPanD(gapminder)
由reprex 包(v0.2.1.9000)于 2018 年 9 月 16 日创建