Skip to content

Commit

Permalink
Merge branch 'devel/4.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
mokztk committed Apr 1, 2021
2 parents fa42d74 + 0393051 commit 1957d64
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 33 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# rocker/tidyverse に日本語設定と頻用パッケージ、および TinyTeX, Radian を追加
# CRAN snapshot: https://packagemanager.rstudio.com/all/__linux__/focal/344 (2020-10-13)
# CRAN snapshotをrocker/tidyverse:4.0.2 の RSPM #344 (2020-10-13) から更新する
# https://packagemanager.rstudio.com/all/__linux__/focal/1069075 (2021-01-29)

FROM rocker/tidyverse:4.0.2

Expand All @@ -20,6 +21,9 @@ RUN set -x \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# CRAN reposに指定しているRSPMのcheckpointを変更
RUN sed -i.bak -e 's%focal/344%focal/1069075%g' /usr/local/lib/R/etc/Rprofile.site

# setup script
# 各スクリプトは改行コード LF(UNIX) でないとエラーになる
COPY my_scripts /my_scripts
Expand Down
13 changes: 5 additions & 8 deletions my_scripts/install_pandas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ set -x
# R から {reticulate} で Python3 を使えるようにセットアップ

# Python3のインストール
apt-get update
apt-get install -y libpython3.8 python3-pandas python3-pip
source /rocker_scripts/install_python.sh

# aptキャッシュを消去
apt-get clean
rm -rf /var/lib/apt/lists/*

# python の共有ライブラリを登録
echo "/usr/lib/x86_64-linux-gnu" > /etc/ld.so.conf.d/libpython3.8.conf
ldconfig

# R に {reticulate} をインストール
R -e 'install.packages("reticulate")'
# グローバルに pandas を入れておく
pip install pandas
13 changes: 7 additions & 6 deletions my_scripts/install_r_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ rm -rf /var/lib/apt/lists/*
# rJava の設定
R CMD javareconf

# RSPMのcheckpointが変わった場合に対応するため、まずcheckpointの状態まで更新する
Rscript -e "update.packages(ask = FALSE)"

# Bioconductor もRSPMからインストールする
echo "options(BioC_mirror = 'https://packagemanager.rstudio.com/bioconductor')" >> /usr/local/lib/R/etc/Rprofile.site
Rscript -e "BiocManager::install(c('graph', 'Rgraphviz'))"
Expand All @@ -42,6 +45,7 @@ install2.r --error --deps TRUE --ncpus -1 --skipinstalled \
car \
survminer \
prophet \
Deducer \
GGally \
ggfortify \
gghighlight \
Expand All @@ -54,7 +58,7 @@ install2.r --error --deps TRUE --ncpus -1 --skipinstalled \
minidown

# since package "export" was removed from CRAN on 2020-02-21,
# install dev version from GitHub repo (commit d29650b / 2020-06-22)
# install dev version from GitHub repo (commit c63141e / 2020-09-09)
install2.r --error --deps TRUE --ncpus -1 --skipinstalled \
officer \
rvg \
Expand All @@ -63,12 +67,9 @@ install2.r --error --deps TRUE --ncpus -1 --skipinstalled \
xtable \
rgl \
stargazer \
tikzDevice
devEMF

installGithub.r tomwenseleers/export@d29650b

# 最新の状態にする
Rscript -e "update.packages(ask = FALSE)"
installGithub.r tomwenseleers/export@c63141e

# cleaning
rm /tmp/downloaded_packages/*
10 changes: 4 additions & 6 deletions my_scripts/install_radian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ set -x

# pip3 を install_pandas.sh などで既に入れていればスキップ
if [ ! -e "/usr/bin/pip3" ]; then
apt-get update
apt-get install -y --no-install-recommends python3-pip
apt-get clean
rm -rf /var/lib/apt/lists/*
source /my_scripts/install_pandas.sh
fi

# radianのインストール
pip3 install -U radian jedi
pip install radian jedi==0.17.2

# radianの設定
cat > /home/rstudio/.radian_profile << EOF
options(radian.color_scheme = "monokai")
#options(radian.color_scheme = "monokai")
options(radian.auto_match = TRUE)
options(radian.highlight_matching_bracket = TRUE)
options(radian.prompt = "\033[0;32mr$>\033[0m ")
options(radian.escape_key_map = list(
list(key = "-", value = " <- "),
Expand Down
2 changes: 1 addition & 1 deletion my_scripts/install_tinytex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

Rscript -e 'tinytex::install_tinytex(dir = "/home/rstudio/.TinyTeX/")'

# {tikzDevice} package 用にLaTeXコンパイラの場所を指定
# 一部の package 用にLaTeXコンパイラの場所を指定
echo "R_LATEXCMD=/home/rstudio/.TinyTeX/bin/x86_64-linux/platex" >> /home/rstudio/.Renviron
echo "R_PDFLATEXCMD=/home/rstudio/.TinyTeX/bin/x86_64-linux/pdflatex" >> /home/rstudio/.Renviron
26 changes: 15 additions & 11 deletions utils/chk_package_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ res <- sapply(
# インストールされている全パッケージ
.packages(all.available = TRUE),
function(pkg){
# 各パッケージの読み込みが成功すれば "ok", 失敗は "BAD"
ifelse(
tryCatch(
temp <- tryCatch(
# 極力メッセージが表示されないようにパッケージを読み込む
suppressMessages(
require(pkg, character.only = TRUE, quietly = TRUE)
),
# エラー、警告は無視する
warning = function(w){ return(FALSE) },
error = function(e){ return(FALSE) }
),
"ok", "BAD")
# バイナリパッケージビルド時のRのバージョン違いは"ok"とする
warning = function(w){
ifelse(regexpr("was\ built\ under\ R\ version", w$message) > 0,
"ok", "Warning")
},
# エラーはとりあえずそのまま "Error" で返す
error = function(e){ return("Error") }
)

# パッケージのロード成功の場合は "ok" で返す
temp <- ifelse(temp == "TRUE", "ok", temp)
})

# 結果が "BAD" のもののみ
res[res == "BAD"]

# 読み込みに失敗したもの
res[res == "Warning"]
res[res == "Error"]

0 comments on commit 1957d64

Please sign in to comment.