2012-10-26 23 views
36

मैं एक आर पैकेज बनाने की कोशिश कर रहा हूं ताकि सीआरएएन पर मैनुअल पढ़ सकें। मुझे पता चल सकता है कि आपके नामस्थान में कार्यों को लोड करने के लिए आयात का उपयोग विवरण फ़ाइल में उपयोग करने के लिए सबसे अच्छा शर्त होगा। विवरण फ़ाइल में जोड़ने के बाद, मैंने इसे नामस्थान फ़ाइल में भी जोड़ा। मैंने आयात कार्यों को आवश्यक कार्यों के साथ नामस्थान फ़ाइल से जोड़ा।नामस्थान निर्भरता की आवश्यकता नहीं

अब जब मैं अपने पैकेज पर आर सीएमडी जांच चलाने, मैं

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

आप अपने NAMESPACE फ़ाइल में 'सीधे ggplot2' से कुछ भी आयात कर रहे हैं? –

+0

हाँ मैं इसका उपयोग कर रहा हूं। –

+0

यदि आपको अभी भी समस्या हो रही है, तो कृपया हमें अपनी DESCRIPTION फ़ाइल दिखाएं। – GSee

उत्तर

42

आप अपने NAMESPACE फ़ाइल में import या importFrom का उपयोग करते हैं मेरी वर्णन फ़ाइल देखें, तो आप अपने विवरण फ़ाइल का आयात खंड में है कि पैकेज के लिए एक प्रवेश करना चाहिए था (जब तक वहाँ एक कारण है है कि आप जिस स्थिति निर्भर करता है उपयोग करने की आवश्यकता पैकेज निर्भर करता है में एक प्रविष्टि है, और नहीं आयात) होना चाहिए

यहाँ 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 के साथ एक पैकेज बनाया। मैंने एक NAMESPACE फ़ाइल को उसी importFrom लाइन के साथ बनाया है जो आप कहते हैं कि आपके पास है।

NAMESPACE फ़ाइल

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

इस बिंदु पर, अगर मैं R CMD check, अपेक्षित तरीके से चलना, मैं कोई त्रुटि मिलती है:

Namespace dependency not required: ‘ggplot2’

लेकिन, अगर मैं ऐसा है कि वर्णन करने के लिए Imports: ggplot2 जोड़ने मेरी वर्णन फ़ाइल निम्नानुसार है, यह बिना किसी समस्या के R CMD check गुजरती है।

वर्णन फ़ाइल

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

क्या यह आरएमडी जांच में विफल नहीं होगा यदि आप वर्णन में आयात अनुभाग शामिल नहीं करते हैं? – Dason

+0

@Dason, नहीं। [विवरण] देखें (https://r-forge.r-project.org/scm/viewvc.php/pkg/xts/DESCRIPTION?view=markup&root=xts) और [NAMESPACE] (https उदाहरण के लिए xts पैकेज के //r-forge.r-project.org/scm/viewvc.php/pkg/xts/NAMESPACE? view = markup और root = xts) ... 'निर्भर करता है: ggplot2' में होना आवश्यक हो सकता है ओपी के लिए वर्णन फ़ाइल हालांकि – GSee

+0

आपको आयात क्षेत्र में होना चाहिए, न कि निर्भर क्षेत्र में। – hadley

संबंधित मुद्दे