Rで解析:GUIでグラフを作成「GrapheR」パッケージ


投稿日: Rの解析に役に立つ記事

簡単にグラフをコマンドで作成できるのであれば必要がないパッケージです。しかし、本パッケージはGUI操作で作成したグラフのコマンドをスクリプトとして保存できるので初心者には大変有益なパッケージと考えます。

パッケージバージョンは1.9-86。windows 10のR version 3.3.2で動作を確認しています。

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

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

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



実行コマンドの紹介

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

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

###データ例の作成#####
n <- 100
TestData <- data.frame("Group" = sample(paste0("Group", 1:10), n, replace = TRUE),
                       "Data1" = sample(rnorm(10), n, replace = TRUE),
                       "Data2" = sample(rnorm(10), n, replace = TRUE),
                       "Data3" = I(sample(c(LETTERS[1:10], NA), n, replace = TRUE)))

########

#GUI操作でグラフを作成:run.GrapheRコマンド
run.GrapheR()

出力例

・GUI操作でグラフを作成:run.GrapheRコマンド

・Boxplot

・棒グラフ

パッケージで出力されるコマンド

GrapheR-YYYY.MM.DD.Rで指定場所に保存されます。冗長な気がしますが、出力結果は何かの参考になると思います。

#----------------------------------------
# GrapheR - session of 2017.01.10
#----------------------------------------
#------------------------------
# GRAPH 1: Box plot
#------------------------------

# Loading of the dataset

dataset <- TestData
attach(dataset)

# Preliminary data creation

interaction <- interaction(Group,Group)

# Graph

boxplot(Data1 ~ interaction, axes=FALSE, ann=FALSE, horizontal=FALSE,
  col=c("#18815f","#b92071","#1beb4f","#88f437","#f98655","#8f97da","#f791af","#CFCFCF","#DBDBDB","#E6E6E6"), boxcol=c("black","black","black","black","black","black","black","black","black","black"), medcol=c("black","black","black","black","black","black","black","black","black","black"),
  whiskcol=c("black","black","black","black","black","black","black","black","black","black"), staplecol=c("black","black","black","black","black","black","black","black","black","black"), whisklty=1,
  outcol=c("black","black","black","black","black","black","black","black","black","black"), range=1.5, notch=FALSE,
  ylim=c(-1.83,0.84))

mtext(c("Group1","Group10","Group2","Group3","Group4","Group5","Group6","Group7","Group8","Group9"), side=1, line=1, at=c(5.5,15.5,25.5,35.5,45.5,55.5,65.5,75.5,85.5,95.5))
axis(2)

title(main="TEST BOXPLOT", col.main="#ff0000")

detach(dataset)

#------------------------------
# GRAPH 2: Bar plot
#------------------------------

# Loading of the dataset

dataset <- TestData
attach(dataset)

# Preliminary data creation

means <- tapply(Data1,Group,function(x) mean(x,na.rm=TRUE))

# Graph

graph <- barplot(means, axes=FALSE, ann=FALSE, col="grey",
  ylim=c(-0.71,0), names=c("Group1","Group10","Group2","Group3","Group4","Group5","Group6","Group7","Group8","Group9"), xpd=FALSE)

abline(h=0)
axis(2)

detach(dataset)

あなたの解析がとっても楽になりますように!!

スポンサードリンク

おすすめコンテンツ


スポンサードリンク