2012-10-26 9 views
36

CRANのマニュアルを読むためにRパッケージをビルドしようとしています。 あなたの名前空間に関数を読み込むためにインポートを使用することは、説明ファイルで使用するのが最善の策だと分かりました。 説明ファイルに追加した後、名前空間ファイルにも追加しました。 必要な機能を持つ名前空間ファイルにimportFromを追加しました。私は私のパッケージのR CMDチェック、 を実行したときにネームスペースの依存関係は不要です

は今、私は

Namespace dependencies not required : 'ggplot2'

さらに情報として、エラーが表示されます。私は記述ファイル依存するにパッケージを追加する場合でも、彼らはロードされて取得されていません。

助けてください。理由がない限り

Package: bigpackage 
Type: Package 
Title: Some title 
Version: 1.0 
Date: 2012-10-25 
Author: Mayank Bansal 
Maintainer: somename 
Imports : R(>= 2.15.1), SweaveListingUtils(>=0.5.5),xtable(>=1.7-0), 
     brew(>=1.0-6), knitr(>=0.8), RHive(>= 0.0-6), ggplot2(>=0.9.2) 
     , brew, knitr 
SystemRequirements : LaTeX(texi2dvi) must be present in the system to 
     create PDF reports 
Description: Some Description 
License: file LICENSE 
LazyLoad: yes 
ByteCompile: true 
OS_type : unix 
+0

あなたの名前空間ファイルに直接ggplot2' 'から何かをインポートしていますか? –

+0

はい私はそれを使用しています。 –

+0

まだ問題が解決しない場合は、DESCRIPTIONファイルを表示してください。 – GSee

答えて

42

あなたの名前空間ファイルにimportまたはimportFromを使用する場合は、以下の私の記述ファイルを見つけてください、あなたは(あなたのDESCRIPTIONファイルのインポート]セクションでそのパッケージのエントリを持っている必要がありますここでは、輸入ではないパッケージが依存にエントリを持つ必要があり、その場合にはDependsとを使用する必要がある、とすることを)

Writing R Extensions

The ‘Imports’ field lists packages whose namespaces are imported from (as specified in the NAMESPACE file) but which do not need to be attached. Namespaces accessed by the ‘::’ and ‘:::’ operators must be listed here, or in ‘Suggests’ or ‘Enhances’ (see below). Ideally this field will include all the standard packages that are used, and it is important to include S4-using packages (as their class definitions can change and the DESCRIPTION file is used to decide which packages to re-install when this happens). Packages declared in the ‘Depends’ field should not also be in the ‘Imports’ field.

0の関連セクションです

私は単一の機能fでパッケージを作成しました。私はあなたの中にあると言っている同じimportFrom行のNAMESPACEファイルを作った。この時点で

NAMESPACEファイル

export("f") 
importFrom("ggplot2","ggplot","geom_histogram") 

私はR CMD checkを実行した場合、予想通り、私はエラーを取得する:

Namespace dependency not required: ‘ggplot2’

しかし、私はそのような記述にImports: ggplot2を追加した場合私のDESCRIPTIONファイルは以下の通りですが、問題なくR CMD checkを渡します。

DESCRIPTIONファイル

Package: anRpackage 
Type: Package 
Title: What the package does (short line) 
Version: 1.0 
Date: 2012-11-07 
Author: Me 
Maintainer: Who to complain to <[email protected]> 
Description: More about what it does (maybe more than one line) 
License: GPL 
Imports: ggplot2 
+0

Rには失敗しますか?説明にImportsセクションが含まれていないかどうかチェックしますか? – Dason

+0

@Dason、No. [DESCRIPTION](https://r-forge.r-project.org/scm/viewvc.php/pkg/xts/DESCRIPTION?view=markup&root=xts)と[NAMESPACE](https ://r-forge.r-project.org/scm/viewvc.php/pkg/xts/NAMESPACE?view = markup&root = xts)xtsパッケージの例... '依存:ggplot2'が必要ですただし、OPのDESCRIPTIONファイル – GSee

+0

これはインポートフィールドにあり、依存フィールドには存在しません。 – hadley