devtools: Tools to make developing R code easier

Rでの開発を促進するツール群

> # devtools::install_github("hadley/devtools")
> library(devtools)

バージョン: 1.12.0


関数名 概略
RCMD Run R CMD xxx from within R
bash Open bash shell in package directory.
build Build package.
build_github_devtools Build the development version of devtools from GitHub.
build_vignettes Build package vignettes.
build_win Build windows binary package.
check Build and check a package, cleaning up automatically on success.
check_failures Parses R CMD check log file for ERRORs, WARNINGs and NOTEs
check_man Check documentation, as 'R CMD check' does.
clean_dll Remove compiled objects from /src/ directory
clean_source Sources an R file in a clean environment.
clean_vignettes Clean built vignettes.
compile_dll Compile a .dll/.so from source.
compiler_flags Default compiler flags used by devtools.
create Creates a new package, following all devtools package conventions.
create_description Create a default DESCRIPTION file for a package.
dev_example Run a examples for an in-development function.
dev_help Read the in-development help for a package loaded with devtools.
dev_mode Activate and deactivate development mode.
devtools Package development tools for R.
document Use roxygen to document a package.
dr_devtools Diagnose potential devtools issues
dr_github Diagnose potential GitHub issues
eval_clean Evaluate code in a clean R session.
github_pull GitHub references
has_devel Check if you have a development environment installed.
help Drop-in replacements for help and ? functions
infrastructure Add useful infrastructure to a package.
inst Get the installation path of a package
install Install a local development package.
install_bioc Install a package from a Bioconductor repository
install_bitbucket Install a package directly from bitbucket
install_cran Attempts to install a package from CRAN.
install_deps Install package dependencies if needed.
install_git Install a package from a git repository
install_github Attempts to install a package directly from GitHub.
install_local Install a package from a local file
install_svn Install a package from a SVN repository
install_url Install a package from a url
install_version Install specified version of a CRAN package.
lint Lint all source files in a package.
load_all Load complete package.
load_code Load R code.
load_data Load data.
load_dll Load a compiled DLL
missing_s3 Find missing s3 exports.
package_deps Find all dependencies of a CRAN or dev package.
package_file Find file in a package.
path Get/set the PATH variable.
release Release package to CRAN.
reload Unload and reload package.
revdep Reverse dependency tools.
revdep_check_save_summary Run R CMD check on all downstream dependencies.
run_examples Run all examples in a package.
session_info Print session information
show_news Show package news
source_gist Run a script on gist
source_url Run a script through some protocols such as http, https, ftp, etc.
spell_check Spell checking
system.file Replacement version of system.file
test Execute all 'test_that' tests in a package.
uninstall Uninstall a local development package.
unload Unload a package
update_packages Update packages that are missing or out-of-date.
use_data Use data in a package.
use_data_raw Use 'data-raw' to compute package datasets.
use_git Initialise a git repository.
use_github Connect a local repo with GitHub.
use_news_md Use NEWS.md
use_package Use specified package.
use_readme_rmd Create README files.
wd Set working directory.
with_debug Temporarily set debugging compilation flags.

create

新規パッケージの作成

> create(path, 
+        description = getOption("devtools.desc"), 
+        check       = FALSE,
+        rstudio     = TRUE)

create_description

packageのDESCRIPTIONファイルを生成する

optionとして、パッケージ作成者 authorとライセンスの情報を登録しておくことができる。

> create_description(path = ".", extra = getOption("devtools.desc"), quiet = FALSE)
> # options(devtools.desc.author  = '"Shinya Uryu" <suika1127@gmail.com> [aut, cre]"'.
> #         devtools.desc.license = "GPL-3")

dev_mode

開発モードへの切り替え

> dev_mode() # on
> dev_mode() # off

開発モードとは?

document

inst

パッケージがインストールされているパスを確認する

> inst(name = "devtools")
[1] "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/devtools"

install_github

GitHubリポジトリにあるRパッケージのインストール

Arguments

  • repo... username/repo の形式で与える文字列
  • username... NULL
  • ref
  • subdir
  • auth_token... プライベートリポジトリからのインストールのために用いるアクセストークン
  • host
  • ...
> install_github("hadley/devtools")

has_devel

開発環境が整備されているか確認

> has_devel()
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file  \
  --no-environ --no-save --no-restore --quiet CMD SHLIB foo.c


Error in dyn.load(dylib): unable to load shared object '/var/folders/8f/s_lbgwks6q7g3lz52q93ngph0000gn/T//Rtmp9qxpSv/foo.so':
  `maximal number of DLLs reached...

infrastructure

パッケージ開発の際に役立つインフラ環境の構築と整備

> use_rstudio()

load_all

> load_all()

use_readme_rmd

.Rmd拡張子のREADMEファイルを生成。knitするとREADME.mdとなる。ディレクトリ内にDESCRIPTIONファイル等があることが前提。

> use_readme_rmd()