ほかのパッケージの関数を使う; github & R package

  • この記事の「なんちゃってRパッケージ」はこちら Here is the github containing files and directories handled in this note.
  • 次のようなMCMCpackパッケージのridichlet()関数を使った関数をパッケージ内に使いたいとする You may want to use some R package(s) in your functions, for example MCMCpackage's rdirichlet() as below.
  • そんなときは、hogePackage hagefunctionをインポートする Add a line importing hoge-package hagefunction.
  • hogePackageがインストールされていなければうまく回らないが、インポートされていればOK When your R environment has installed the package already, your own package's function will work fine.
#' @export
#' @importFrom MCMCpack rdirichlet

myfxDirichlet <- function(n,m){
	MCMCpack::rdirichlet(n,rep(1,m))
}