Last active
June 6, 2022 12:31
-
-
Save tetlabo/b718848470443865e8a587659c4bf0d2 to your computer and use it in GitHub Desktop.
RStudio CloudにRMeCabパッケージをインストールする手順
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("withr") | |
# 下記の "/opt/R/4.1.3/lib/R/bin" は実行環境によって変わりますので、適宜読み替えてください。 | |
home <- Sys.getenv("HOME") | |
Sys.setenv(PATH=paste0("/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/R/4.1.3/lib/R/bin:/usr/lib/rstudio-server/bin/postback:", home, "/usr/local/bin")) | |
Sys.setenv(CPPFLAGS=paste0("-I", home, "/usr/local/include")) | |
Sys.setenv(LDFLAGS=paste0("-I", home, "/usr/local/lib")) | |
Sys.setenv(LD_LIBRARY_PATH=paste0(home, "/usr/local/lib")) | |
withr::with_makevars(c(CPPFLAGS=paste0("-I", home, "/usr/local/include"), LDFLAGS=paste0("-L", home, "/usr/local/lib"), LD_LIBRARY_PATH=paste0(home, "/usr/local/lib")), install.packages("RMeCab", repos = "https://rmecab.jp/R"), assignment="+=") | |
dyn.load(paste0(home, "/usr/local/lib/libmecab.so.2")) | |
library(RMeCab) | |
RMeCabC("すもももももももものうち") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment