easystats生态之report包,报告你统计的一切需要

方法总览


#英文教程原网址:https://easystats.github.io/report/

library(tidyverse)
library(easystats)

rm(list = ls()) 
options(stringsAsFactors = T)

#基本用法解释
# The report package works in a two step fashion. 
# First, you create a report object with the report() function. 
# Then, this report object can be displayed either textually (the default output) 
# or as a table, using as.data.frame(). 
# Moreover, you can also access a more digest and compact version of the report using summary() on the report object.

#报告数据集情况
report(iris)

#可以用summary精简报告
iris %>%
  select(-starts_with("Sepal")) %>%
  group_by(Species) %>%
  report() %>%
  summary()

#对T检验进行报告
report(t.test(mtcars$mpg ~ mtcars$am))


#对结构进行整理并构成列表
res<- cor.test(iris$Sepal.Length, iris$Sepal.Width) %>%
  report() %>%
  as.data.frame();res

#对方差分析进行报告
aov(Sepal.Length ~ Species, data = iris) %>%
  report()


#对广义线性模型中的逻辑回归进行报告
model <- glm(vs ~ mpg * drat, data = mtcars, family = "binomial")

report(model)


#混合效应模型
library(lme4)

model <- lme4::lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris)

report(model)

#提取最终报告的部分内容
model <- lm(Sepal.Length ~ Species, data = iris)

report_model(model)
report_performance(model)
report_statistics(model)


#分组汇总数据并报告
res1<- iris %>%
  group_by(Species) %>%
  report()%>%
  as.data.frame()

res2<- iris %>%
  group_by(Species) %>%
  report_table()

你可能感兴趣的:(easystats生态之report包,报告你统计的一切需要)