美圖神器ggstatsplot-專為學(xué)術(shù)論文而生
在CRAN(comprehensive R Achive Netwokrk)中已有13000多個R包了
簡單講ggstatsplot能夠提供更為豐富信息的包,其實就是畫出高質(zhì)量的圖
不需要我們花費(fèi)過多的精力去調(diào)整繪圖細(xì)節(jié),舉個例子
一般的探索性數(shù)據(jù)分過程析包括數(shù)據(jù)可視化與數(shù)據(jù)統(tǒng)計兩個部分懂讯,而ggstatsplot正是達(dá)到兩者結(jié)合的目的
舉例說明
組間比較-ggbetweenstats
library(ggstatsplot)
library(ggplot2)
p代表參數(shù)檢驗署咽,np代表非參數(shù)
mpaa是分類變量,y是數(shù)值型變量
head(movies_long)
## # A tibble: 6 x 8
## title year length budget rating votes mpaa genre
## <chr> <int> <int> <dbl> <dbl> <int> <fct> <fct>
## 1 Shawshank Redemption, The 1994 142 25 9.1 149494 R Drama
## 2 Lord of the Rings: The Ret~ 2003 251 94 9 103631 PG-13 Acti~
## 3 Lord of the Rings: The Fel~ 2001 208 93 8.8 157608 PG-13 Acti~
## 4 Lord of the Rings: The Two~ 2002 223 94 8.8 114797 PG-13 Acti~
## 5 Pulp Fiction 1994 168 8 8.8 132745 R Drama
## 6 Schindler's List 1993 195 25 8.8 97667 R Drama
ggbetweenstats(
data = movies_long,
x = mpaa, # > 2 groups
y = rating,
type = "p", # default
messages = FALSE
)
默認(rèn)參數(shù)繪圖
ggbetweenstats(
data = movies_long,
x = mpaa,
y = rating
)
配對比較
pairwise.display參數(shù)控制曾現(xiàn)的比較,ns無意義,all,所有,s有意義的
ggbetweenstats(
data = movies_long,
x = mpaa,
y = rating,
type = "np",
mean.ci = TRUE,
pairwise.comparisons = TRUE,
pairwise.display = "s",
p.adjust.method = "fdr",
messages = FALSE
)
調(diào)整顏色,主題,可信區(qū)間調(diào)整,突出值標(biāo)記
confi.level:可信區(qū)間調(diào)整,ggtheme主題,pallete:顏色調(diào)用
outlier:超出界限標(biāo)記
ggbetweenstats(
data = movies_long,
x = mpaa,
y = rating,
type = "r",
conf.level = 0.99,
pairwise.comparisons = TRUE,
pairwise.annotation = "p",
outlier.tagging = TRUE,
outlier.label = title,
outlier.coef = 2,
ggtheme = hrbrthemes::theme_ipsum_tw(),
palette = "Darjeeling2",
package = "wesanderson",
messages = FALSE
)
ggwithinstats組內(nèi)比較
圖還是非常美觀铐尚,就不去細(xì)講每個參數(shù)了,需要時調(diào)用即可哆姻,這也是作者的意圖
ggwithinstats(
data = WRS2::WineTasting,
x = Wine, # > 2 groups
y = Taste,
pairwise.comparisons = TRUE,
pairwise.annotation = "p",
ggtheme = hrbrthemes::theme_ipsum_tw(),
ggstatsplot.layer = FALSE,
messages = FALSE
)
相關(guān)性圖-ggscatterstats
代碼簡介宣增,細(xì)節(jié)豐富
ggscatterstats(
data = movies_long,
x = budget,
y = rating,
type = "p", # default #<<<
conf.level = 0.99,
marginal=F,
messages = TRUE
)
其實還可以畫很多其它的圖,顏值都非常高矛缨,這里不再過多介紹爹脾,真正做到一圖勝千言
總結(jié)一下這個包的局限性:
- 雖然圖的信息量大,但有時比如presentation箕昭,時間不夠灵妨,圖信息過多反而不利于簡明扼要的傳達(dá)信息
- 另外就是計算的統(tǒng)計量比較單一