パッケージ作ってて、そのパッケージの中のある関数中で他のパッケージの関数呼ぶ場合、DESCRIPTIONのImports書いてるだけじゃだめぽなんですが、 これちゃんとNAMESPACEにImport書かないとダメなんでしたっけ…?

完全備忘録。

hoxo_n パッケージ作ってて、そのパッケージの中のある関数中で他のパッケージの関数呼ぶ場合、DESCRIPTIONのImports書いてるだけじゃだめぽなんですが、
これちゃんとNAMESPACEにImport書かないとダメなんでしたっけ…?
聖書にちゃんと書いてありました。。。
http://r-pkgs.had.co.nz/namespace.html#imports
```R functions
If you are using just a few functions from another package, my recommendation is to note the package name in the Imports: field of the DESCRIPTION file and call the function(s) explicitly using ::, e.g., pkg::fun().

If you are using functions repeatedly, you can avoid :: by importing the function with @importFrom pgk fun. This also has a small performance benefit, because :: adds approximately 5 µs to function evaluation time.

Alternatively, if you are repeatedly using many functions from another package, you can import all of them using @import package. This is the least recommended solution because it makes your code harder to read (you can't tell where a function is coming from), and if you @import many packages, it increases the chance of conflicting function names.
```

hoxo_m
```#' @importFrom package method
```
みたいに書いておくと roxygen がよしなにやってくれます
hoxo_n 親分は packagename::methodじゃなくてImportしちゃうマンかー
これ使用している関数の上に書いておかないと収集つかなくなりそうで、それならパッケージ名毎回書いてもいいかなって思いだしてました
あ、そうかいてるのね、おれもそうしよう
https://github.com/hoxo-m/bayesopt/blob/master/R/bayesopt.R
johndoe たまに書くと忘れているので、忘れていたら@hoxo_mか@hoxo_nのコードを読むと心に刻みました
hoxo_n おれもわすれているし、Pandasの勉強をしてモテたいです。
hoxo_m 昔は `pkg::fun()` マンだったけど CRAN 通すときにこの書き方知ってこっち派になりました。
hoxo_n Why are you usin `pkg::fun()` ? 事案だ (edited)
hoxo_m わかんないけど CRAN の中の人にこっちの書き方指定されたんですよねー。どっちでもいいのかもしれんけど。
hoxo_n よくわからないことに安易に迎合しない!それが俺たち(略
johndoe さきほどのhoxo_nの聖書からの引用に少し速くなるよ(マイクロ秒レベル)って書いてるのでそれくらいの利点と認識しました
hoxo_m 一つだけわかるのは `pkg::fun()` の書き方だと ` .onAttach()` が呼ばれないと思うんですよね。例えば rstan なんかは `.onAttach()` でいろいろ前処理やってるので `rstan::stan()` みたいな書き方だととうまく動かないと思います。 (edited)
johndoe みなさんパスをの文字列操作時は、paste()とかsprintf()じゃなくてfile.path()を使っていますか?
hoxo_m 昔は `file.path()` 使ってましたけど、最近はあんまりこだわってないです (edited)