RStudioの設定
.Rprofileは、C:\Users\user\Documents\.Rprofileにある。
Sys.setenv(LANG = "en")でメッセージを英語にする。
R環境の構築メモ(2019/09)
R環境を作る時によく忘れるのでメモ
メモを作成したOS環境は、GCEのUbuntu 18.04 LTS Minimal。
Rprofile
メッセージを英語にするため、~/.Rprofileに「Sys.setenv(LANGUAGE = "en")」を記載。r4dsの1.6 Getting help and learning moreを参考。
https://r4ds.had.co.nz/introduction.html
RStudioのServer
Webブラウザ経由での操作が可能になる。
https://www.rstudio.com/products/rstudio/download-server/
Rのライブラリ
- tidyverse
- lubridate
- caret
- doParallel
- randomForest
- broom
- forecast
- gridExtra
- jsonlite
- knitr
- scales
- sweep
- timetk
- vars
- ggthemes
- ggmosaic
- fastDummies
- lightgbm
- tictoc
- MLmetrics
- moments
- rattle
- rsample
- keras
- glmnet
tidyverseの時には、OSソフトのインストールが必要になる。
sudo apt install libssl-dev libxml2-dev libcurl4-openssl-dev
lightgbmはR3.6.1だとinstall.packagesで入れられなかった。
https://github.com/microsoft/LightGBM/tree/master/R-package
より、コマンドラインでインストール
sudo apt install cmake
git clone --recursive https://github.com/microsoft/LightGBM
cd LightGBM
Rscript build_r.R
Rmarkdown
renderコマンドで生成する場合はpandocが必要.
sudo apt install pandoc
EmacsでRmarkdownを使う
Rmarkdownを利用するとhtml形式でレポートが作成できて、グループで共有するのに便利なので導入したいと思います。
EmacsのESSから離れたくないので、Emacs上で使えないかを探しました。
以下を参考に、polymodeを導入すると実現できました。
Emacs で knitr と R markdown を使う方法 (Rmd) | Futurismo
インストール
M-x
package-install
polymode
init.elの設定
(require 'poly-R)
(require 'poly-markdown)
Rmdファイルからhtmlを作成する。
library(rmarkdonw) setwd("dir-of-sample") # 必要に応じて、作業フォルダを変更します
getwd() #作業フォルダの確認 render("xxxx.Rmd") # 変換