Rで解析:3評価基準をヒートマップで表示「contribution」パッケージ

“Major”,”Minor”,”None”の3評価基準をヒートマップで表示するコマンドと27種類のカラーパレットが収録されているパッケージの紹介です。簡単に全体像を理解できます。なお、3評価基準は”Major”,”Minor”,”None”に固定されています。データの基準を合わせることで利用の幅が広がるのではと思います。

パッケージバージョンは0.2.1。実行コマンドはwindows 11のR version 4.1.2で確認しています。

パッケージのインストール

下記、コマンドを実行してください。

#パッケージのインストール
install.packages("contribution")

実行コマンド

詳細はコメント、パッケージのヘルプを確認してください。

#パッケージの読み込み
library("contribution")

###データ例の作成#####
#tidyverseパッケージがなければインストール
if(!require("tidyverse", quietly = TRUE)){
  install.packages("tidyverse");require("tidyverse")
}
set.seed(1234)
n <- 100
TestData <- tibble(Y_Label = rep(paste0("DATA", 1:10), length = n,
                                 time = 10),
                   X_LAbel = rep(paste0("Q", 1:10), length = n,
                                 each = 10),
                   DATA = sample(c("Major", "Minor", "None"), n,
                                 replace = TRUE)) %>%
  pivot_wider(names_from = X_LAbel, values_from = DATA)
########

#"Major","Minor","None"&#12398;&#65299;&#35413;&#20385;&#22522;&#28310;&#12434;&#12498;&#12540;&#12488;&#12510;&#12483;&#12503;&#12391;&#34920;&#31034;:generate&#12467;&#12510;&#12531;&#12489;
#Y&#12521;&#12505;&#12523;&#12434;&#12477;&#12540;&#12488;:sort&#12458;&#12503;&#12471;&#12519;&#12531;
#&#12475;&#12523;&#12398;&#33394;&#12434;&#25351;&#23450;:color_map&#12458;&#12503;&#12471;&#12519;&#12531;;ggplot2&#12398;scale_fill_brewer&#12467;&#12510;&#12531;&#12489;&#12434;&#21033;&#29992;
generate(data = TestData, sort = TRUE,
         color_map = scale_fill_brewer(palette = "Oranges"),
         text_angle_x = 20, font_size_x = 16,
         font_size_y = 16, text_angle_y = 0,
         show_legend = TRUE)

#&#21454;&#37682;&#12497;&#12524;&#12483;&#12488;&#12434;&#34920;&#31034;:show_palette&#12467;&#12510;&#12531;&#12489;
show_palette()

出力例

・generateコマンド

・show_paletteコマンド


少しでも、あなたの解析が楽になりますように!!

Prices and shipping availability may change. Please refer to the product page at time of purchase.
Content displayed on this site is provided by Amazon and may be updated or removed.
Amazon Associate, karada-good earns income through qualifying sales.
タイトルとURLをコピーしました