
Rは統計解析等に強いプログラミング言語。
RStudioは、Rを使うための総合開発環境(IDE)の一つ。
両方とも無料でダウンロードできる。
Rのダウンロード/インストール
Rのダウンロード
CRANウェブサイトへ。
Download and Install R Precompiled binary distributions of the base system and contributed packages, Windows and Mac users most likely want one of these versions of R: Download R for Linux (Debian, Fedora/Redhat, Ubuntu) Download R for macOS Download R for Windows
私はWindowsを使っているので、「Download R for Windows」を選択。
(Macの場合は「Download R for macOS」, Linuxの場合は「Download for Linux」)

「R for Windows」画面で、「install R for the first time」をクリック。

一番上にある最新Ver.をダウンロードする。

Rのインストール
ダウンロードが完了したら、アプリケーションをダブルクリックしてインストール開始。
言語を選択し、

インストラクションに従って進む(ほぼデフォルトでOK。)

最後に「Finish」でインストール完了。

RのGuiはこんな感じ。

RStudioのダウンロード/インストール
RStudioのダウンロード
RStudioは、RStudioのウェブサイトからダウンロードできる。
The best data science is open source. Posit is committed to creating incredible open-source tools for individuals, teams, and enterprises.
上のタブにある「OPEN SOURCE」から、「RSTUDIO IDE」を選択。

下の方にある「DOWNLOAD TSTUDIO DESKTOP」を選択。

「RStudio IDE」のページに飛ぶので、「DOWNLOAD RSTUDIO」を選択。

「RStudio Desktop」のページに飛ぶので、「2.Install RStudio」の「DOWNLOAD RSTUDIO DESKTOP FOR WINDOWS」を選択。
(その他のOSに対しては、下の方にリストがある。)

RStudioのインストール
ダウンロードが完了したら、アプリケーションをダブルクリックしてインストール開始。

インストールの場所を指定して、「Install」。

インストールが開始される。「Finish」で完了。

RStudioのレイアウト
インストール直後にRStudioを開くと、レイアウトは3つのペイン(Pane)から成っている。
ここで、コンソールの右上にあるマークをクリックすると、スクリプトを書く「ソース(Source pane)」が現れる。

各ペインの役割
基本的には、以下の4つのペインを使っていく。
左上:ソース(Source pane)
スクリプトを書くところ。できたスクリプトは下のConsoleで実行される。スクリプトを書き終わったら保存できる。
左下:コンソール(Console pane)
コンソール。ここに直接コードを書いても良いけれど、保存はできない。
右上:環境(Environments pane)等
作ったベクターやテーブルなどはここに一覧が作成される。
右下:出力(Output pane)等
プロット等の出力の他、ファイルやパッケージの確認や実行、ヘルプやチュートリアルもここで確認できる。

ペインのレイアウト変更
各ペインのレイアウトは、Tools > Global Options > pane Layout で変更できる。

RStudioのテーマを変更
テーマを変更する必要はないけれども、私の場合は、個人的に目に優しく、ストレスの少ないテーマに変更している。
方法は下記参照。
RStudioの画面は、デフォルトでは白いバックグラウンドになっている これを、私の好きなDark colorに変更する方法 1. Tools -> Global Options -> Appe …